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
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/rubocop-1.35.1/lib/rubocop/cli/command/show_docs_url.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/rubocop-1.35.1/lib/rubocop/cli/command/show_docs_url.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/rubocop-1.35.1/lib/rubocop/cli/command/show_docs_url.rb
rubocop-1.63.4 lib/rubocop/cli/command/show_docs_url.rb
rubocop-1.63.3 lib/rubocop/cli/command/show_docs_url.rb
rubocop-1.63.2 lib/rubocop/cli/command/show_docs_url.rb
harbr-2.8.1 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cli/command/show_docs_url.rb
rubocop-1.63.1 lib/rubocop/cli/command/show_docs_url.rb
rubocop-1.63.0 lib/rubocop/cli/command/show_docs_url.rb
bison-0.1.0 vendor/bundle/ruby/3.2.0/gems/rubocop-1.62.1/lib/rubocop/cli/command/show_docs_url.rb
rubocop-1.62.1 lib/rubocop/cli/command/show_docs_url.rb
rubocop-1.62.0 lib/rubocop/cli/command/show_docs_url.rb
rubocop-1.61.0 lib/rubocop/cli/command/show_docs_url.rb
mlh-rubocop-config-1.0.3 vendor/bundle/ruby/3.2.0/gems/rubocop-1.60.2/lib/rubocop/cli/command/show_docs_url.rb
rubocop-1.60.2 lib/rubocop/cli/command/show_docs_url.rb
study_line-0.2.7 vendor/bundle/ruby/3.2.0/gems/rubocop-1.60.0/lib/rubocop/cli/command/show_docs_url.rb
study_line-0.2.6 vendor/bundle/ruby/3.2.0/gems/rubocop-1.60.0/lib/rubocop/cli/command/show_docs_url.rb
study_line-0.2.5 vendor/bundle/ruby/3.2.0/gems/rubocop-1.60.0/lib/rubocop/cli/command/show_docs_url.rb
study_line-0.2.4 vendor/bundle/ruby/3.2.0/gems/rubocop-1.60.0/lib/rubocop/cli/command/show_docs_url.rb
study_line-0.2.3 vendor/bundle/ruby/3.2.0/gems/rubocop-1.60.0/lib/rubocop/cli/command/show_docs_url.rb