Class: RuboCop::Cop::Chef::ChefStyle::UsePlatformHelpers
- Inherits:
-
RuboCop::Cop
- Object
- RuboCop::Cop
- RuboCop::Cop::Chef::ChefStyle::UsePlatformHelpers
- Defined in:
- lib/rubocop/cop/chef/style/use_platform_helpers.rb
Overview
Constant Summary collapse
- MSG =
"Use platform? and platform_family? helpers for checking a node's platform".freeze
Instance Method Summary collapse
Instance Method Details
#autocorrect(node) ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/rubocop/cop/chef/style/use_platform_helpers.rb', line 50 def autocorrect(node) lambda do |corrector| platform_check?(node) do |type, operator, plat| corrected_string = operator == :!= ? '!' : '' corrected_string << "#{type.value}?('#{plat.value}')" corrector.replace(node.loc.expression, corrected_string) end end end |
#on_send(node) ⇒ Object
44 45 46 47 48 |
# File 'lib/rubocop/cop/chef/style/use_platform_helpers.rb', line 44 def on_send(node) platform_check?(node) do add_offense(node, location: :expression, message: MSG, severity: :refactor) end end |