```ruby
require "jekyll"
require "uri"

module Jekyll
  module GitHubMetadata
    class GHPMetadataGenerator < Jekyll::Generator
      safe true

      attr_reader :site

      def generate(site)
        Jekyll::GitHubMetadata.log :debug, "Initializing..."
        @site = site
        site.config["github"] = github_namespace

        # Set `site.url` and `site.baseurl` if unset and in production mode.
        if Jekyll.env == "production"
          html_url = URI(drop.url)

          # baseurl tho
          if site.config["baseurl"].to_s.empty? && !["", "/"].include?(html_url.path)
            site.config["baseurl"] = html_url.path
          end

          # remove path so URL doesn't have baseurl in it
          html_url.path = ""
          site.config["url"] ||= html_url.to_s
        end

        @site = nil
      end

      private

      def github_namespace
        case site.config["github"]
        when nil
          drop
        when Hash, Liquid::Drop
          Jekyll::Utils.deep_merge_hashes(drop, site.config["github"])
        else
          site.config["github"]
        end
      end

      def drop
        @drop ||= MetadataDrop.new(site)
      end
    end
  end
end
```

Refactor so rubocop is happy
user
```ruby
require "jekyll"
require "uri"

module Jekyll
  module GitHubMetadata
    class GHPMetadataGenerator < Jekyll::Generator
      safe true

      attr_reader :site

      def generate(site)
        Jekyll::GitHubMetadata.log :debug, "Initializing..."
        @site = site
        site.config["github"] = github_namespace
        set_url_and_baseurl_fallbacks!
        @site = nil
      end

      private

      def github_namespace
        case site.config["github"]
        when nil
          drop
        when Hash, Liquid::Drop
          Jekyll::Utils.deep_merge_hashes(drop, site.config["github"])
        else
          site.config["github"]
        end
      end

      def drop
        @drop ||= MetadataDrop.new(site)
      end

      # Set `site.url` and `site.baseurl` if unset and in production mode.
      def set_url_and_baseurl_fallbacks!
        return unless Jekyll.env == "production"

        parsed_url = URI(drop.url)

        # baseurl tho
        if site.config["baseurl"].to_s.empty? && !["", "/"].include?(parsed_url.path)
          site.config["baseurl"] = parsed_url.path
        end

        # remove path so URL doesn't have baseurl in it
        parsed_url.path = ""
        site.config["url"] ||= parsed_url.to_s
      end
    end
  end
end
```
assistant