Sha256: d19b0507c28f68682b38cb6fe5df82dc53ad0ddd1178de67cfe57d5468e49db8

Contents?: true

Size: 1000 Bytes

Versions: 193

Compression:

Stored size: 1000 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  class CLI
    module Command
      # Prints out url to documentation of provided cops
      # or documentation base url by default.
      # @api private
      class ShowDocsUrl < Base
        self.command_name = :show_docs_url

        def initialize(env)
          super

          @config = @config_store.for(Dir.pwd)
        end

        def run
          print_documentation_url
        end

        private

        def print_documentation_url
          puts Cop::Documentation.default_base_url if cops_array.empty?

          cops_array.each do |cop_name|
            cop = registry_hash[cop_name]

            next if cop.empty?

            puts Cop::Documentation.url_for(cop.first, @config)
          end

          puts
        end

        def cops_array
          @cops_array ||= @options[:show_docs_url]
        end

        def registry_hash
          @registry_hash ||= Cop::Registry.global.to_h
        end
      end
    end
  end
end

Version data entries

193 entries across 184 versions & 17 rubygems

Version Path
harbr-0.1.74 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cli/command/show_docs_url.rb
harbr-0.1.73 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cli/command/show_docs_url.rb
harbr-0.1.72 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cli/command/show_docs_url.rb
harbr-0.1.71 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cli/command/show_docs_url.rb
harbr-0.1.70 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cli/command/show_docs_url.rb
harbr-0.1.69 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cli/command/show_docs_url.rb
harbr-0.1.68 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cli/command/show_docs_url.rb
harbr-0.1.67 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cli/command/show_docs_url.rb
harbr-0.1.66 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cli/command/show_docs_url.rb
harbr-0.1.65 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cli/command/show_docs_url.rb
harbr-0.1.64 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cli/command/show_docs_url.rb
harbr-0.1.63 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cli/command/show_docs_url.rb
harbr-0.1.62 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cli/command/show_docs_url.rb
harbr-0.1.61 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cli/command/show_docs_url.rb
harbr-0.1.60 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cli/command/show_docs_url.rb
harbr-0.1.59 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cli/command/show_docs_url.rb
harbr-0.1.58 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cli/command/show_docs_url.rb
harbr-0.1.57 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cli/command/show_docs_url.rb
harbr-0.1.56 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cli/command/show_docs_url.rb
harbr-0.1.55 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cli/command/show_docs_url.rb