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.
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rubocop/options.rb', line 26 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 |
# File 'lib/rubocop/options.rb', line 16 def parse(args) (args).parse!(args) validate_compatibility [@options, args] end |