Class: RuboCop::Options
- Inherits:
-
Object
- Object
- RuboCop::Options
- Defined in:
- lib/rubocop/options.rb
Overview
This class handles command line options.
Constant Summary collapse
- DEFAULT_FORMATTER =
'progress'
- EXITING_OPTIONS =
[:version, :verbose_version, :show_cops]
- DEFAULT_MAXIMUM_EXCLUSION_ITEMS =
15
Class Method Summary collapse
-
.validate_cop_list(names) ⇒ Object
Cop name validation must be done later than option parsing, so it's not called from within this class.
Instance Method Summary collapse
-
#initialize ⇒ Options
constructor
A new instance of Options.
- #parse(args) ⇒ Object
Constructor Details
#initialize ⇒ Options
Returns a new instance of Options.
12 13 14 |
# File 'lib/rubocop/options.rb', line 12 def initialize @options = {} end |
Class Method Details
.validate_cop_list(names) ⇒ Object
Cop name validation must be done later than option parsing, so it's not called from within this class.
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rubocop/options.rb', line 33 def self.validate_cop_list(names) return unless names namespaces = Cop::Cop.all.types.map { |t| t.to_s.capitalize } names.each do |name| next if Cop::Cop.all.any? { |c| c.cop_name == name } || namespaces.include?(name) fail ArgumentError, "Unrecognized cop or namespace: #{name}." end end |
Instance Method Details
#parse(args) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rubocop/options.rb', line 16 def parse(args) (args).parse!(args) # The --no-color CLI option sets `color: false` so we don't want the # `no_color` key, which is created automatically. @options.delete(:no_color) validate_compatibility if @options[:stdin] && !args.one? fail ArgumentError, '-s/--stdin requires exactly one path.' end [@options, args] end |