Class: RuboCop::Cop::Chef::RedundantCode::StringPropertyWithNilDefault
- Extended by:
- AutoCorrector
- Includes:
- RangeHelp
- Defined in:
- lib/rubocop/cop/chef/redundant/string_property_with_nil_default.rb
Overview
Properties have a nil value by default so there is no need to set the default value to nil.
Constant Summary collapse
- MSG =
'Properties have a nil value by default so there is no need to set the default value to nil.'
- RESTRICT_ON_SEND =
[:property].freeze
Instance Method Summary collapse
Methods inherited from Base
Instance Method Details
#on_send(node) ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'lib/rubocop/cop/chef/redundant/string_property_with_nil_default.rb', line 52 def on_send(node) string_property_with_nil_default?(node) do |nil_default| add_offense(nil_default, severity: :refactor) do |corrector| range = range_with_surrounding_comma(range_with_surrounding_space(range: nil_default.loc.expression, side: :left), :left) corrector.remove(range) end end end |