Class: RuboCop::Cop::Chef::Style::TrueClassFalseClassResourceProperties

Inherits:
Base
  • Object
show all
Extended by:
AutoCorrector
Defined in:
lib/rubocop/cop/chef/style/true_false_resource_properties.rb

Overview

When setting the allowed types for a resource to accept either true or false values it’s much simpler to use true and false instead of TrueClass and FalseClass.

Examples:


### incorrect
property :foo, [TrueClass, FalseClass]

### correct
property :foo, [true, false]

Constant Summary collapse

MSG =
"When setting the allowed types for a resource to accept either true or false values it's much simpler to use true and false instead of TrueClass and FalseClass."
RESTRICT_ON_SEND =
[:property, :attribute].freeze

Instance Method Summary collapse

Methods inherited from Base

#target_chef_version

Instance Method Details

#on_send(node) ⇒ Object



42
43
44
45
46
47
48
# File 'lib/rubocop/cop/chef/style/true_false_resource_properties.rb', line 42

def on_send(node)
  trueclass_falseclass_property?(node) do |types|
    add_offense(node, severity: :refactor) do |corrector|
      corrector.replace(types, '[true, false]')
    end
  end
end