Class: RuboCop::Schema::DefaultsRipper

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop/schema/defaults_ripper.rb

Constant Summary collapse

EXCLUDE_ATTRIBUTES =
Set.new(%w[Description VersionAdded VersionChanged StyleGuide]).freeze
TYPE_MAP =
{
  integer: [Integer],
  number:  [Float],
  boolean: [TrueClass, FalseClass],
  string:  [String],
  array:   [Array]
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(defaults) ⇒ DefaultsRipper

Returns a new instance of DefaultsRipper.

Parameters:

  • defaults (Hash)


20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/rubocop/schema/defaults_ripper.rb', line 20

def initialize(defaults)
  @cops = defaults.map do |cop_name, attributes|
    next unless attributes.is_a? Hash

    CopInfo.new(
      name:               cop_name,
      description:        attributes['Description'],
      enabled_by_default: attributes['Enabled'] == true,
      attributes:         transform_attributes(attributes)
    )
  end.compact
end

Instance Attribute Details

#copsArray<CopInfo> (readonly)

Returns:



17
18
19
# File 'lib/rubocop/schema/defaults_ripper.rb', line 17

def cops
  @cops
end