Class: RuboCop::CLI::Command::ShowCops Private
Do not use. This class is for internal use only.
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
Base
|
|
Instance Chain:
self,
Base
|
|
Inherits: |
RuboCop::CLI::Command::Base
|
Defined in: | lib/rubocop/cli/command/show_cops.rb |
Overview
Shows the given cops, or all cops by default, and their configurations for the current directory.
Class Attribute Summary
Base
- Inherited
Class Method Summary
- .new(env) ⇒ ShowCops constructor Internal use only
Base
- Inherited
Instance Attribute Summary
Instance Method Summary
- #run Internal use only
- #config_lines(cop) private Internal use only
- #cops_of_department(cops, department) private Internal use only
- #print_available_cops private Internal use only
- #print_cop_details(cops) private Internal use only
- #print_cops_of_department(registry, department, show_all) private Internal use only
- #selected_cops_of_department(cops, department) private Internal use only
Instance Method Details
#config_lines(cop) (private)
[ GitHub ]# File 'lib/rubocop/cli/command/show_cops.rb', line 67
def config_lines(cop) cnf = @config.for_cop(cop) cnf.to_yaml.lines.to_a.drop(1).map { |line| " #{line}" } end
#cops_of_department(cops, department) (private)
[ GitHub ]# File 'lib/rubocop/cli/command/show_cops.rb', line 63
def cops_of_department(cops, department) cops.with_department(department).sort! end
#print_available_cops (private)
[ GitHub ]# File 'lib/rubocop/cli/command/show_cops.rb', line 25
def print_available_cops registry = Cop::Registry.global show_all = @options[:show_cops].empty? puts "# Available cops (#{registry.length}) + config for #{Dir.pwd}: " if show_all registry.departments.sort!.each do |department| print_cops_of_department(registry, department, show_all) end end
#print_cop_details(cops) (private)
[ GitHub ]# File 'lib/rubocop/cli/command/show_cops.rb', line 48
def print_cop_details(cops) cops.each do |cop| puts '# Supports --autocorrect' if cop.support_autocorrect? puts "#{cop.cop_name}:" puts config_lines(cop) puts end end
#print_cops_of_department(registry, department, show_all) (private)
[ GitHub ]# File 'lib/rubocop/cli/command/show_cops.rb', line 36
def print_cops_of_department(registry, department, show_all) selected_cops = if show_all cops_of_department(registry, department) else selected_cops_of_department(registry, department) end puts "# Department '#{department}' (#{selected_cops.length}):" if show_all print_cop_details(selected_cops) end
#run
[ GitHub ]# File 'lib/rubocop/cli/command/show_cops.rb', line 19
def run print_available_cops end
#selected_cops_of_department(cops, department) (private)
[ GitHub ]# File 'lib/rubocop/cli/command/show_cops.rb', line 57
def selected_cops_of_department(cops, department) cops_of_department(cops, department).select do |cop| @options[:show_cops].include?(cop.cop_name) end end