123456789_123456789_123456789_123456789_123456789_

Class: RuboCop::CLI::Command::Explain Private

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Base
Instance Chain:
self, CopNames, Base
Inherits: RuboCop::CLI::Command::Base
Defined in: lib/rubocop/cli/command/explain.rb

Overview

Explains what cops do, as described by ::RuboCop::Cop::CopExplanation.

Class Attribute Summary

Base - Inherited

Class Method Summary

Base - Inherited

Instance Attribute Summary

Base - Inherited

Instance Method Summary

CopNames - Included

#cop_class_for

Not memoized: the MCP server lives long enough for a plugin to register a cop after a lookup has missed it.

#department?, #department_message,
#known_cop_classes

The cops among names that exist, so a command can report on what it understood before #validate_cop_names! objects to the rest.

#unknown_cop_message, #validate_cop_names!

Constructor Details

.new(env) ⇒ Explain

[ GitHub ]

  
# File 'lib/rubocop/cli/command/explain.rb', line 13

def initialize(env)
  super

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

Instance Method Details

#run

[ GitHub ]

  
# File 'lib/rubocop/cli/command/explain.rb', line 19

def run
  names = @options[:explain]

  known_cop_classes(names).each_with_index do |cop_class, index|
    puts if index.positive?
    puts Cop::CopExplanation.new(cop_class, @config)
  end

  # Checked after printing, so a typo in a list does not cost you the
  # explanations you asked for alongside it.
  validate_cop_names!(names)
end