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 node platform'.freeze
Instance Method Summary collapse
Instance Method Details
#autocorrect(node) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/rubocop/cop/chef/style/use_platform_helpers.rb', line 46 def autocorrect(node) lambda do |corrector| platform_check?(node) do |type, plat| corrector.replace(node.loc.expression, "#{type.value}?('#{plat.value}')") end end end |
#on_send(node) ⇒ Object
40 41 42 43 44 |
# File 'lib/rubocop/cop/chef/style/use_platform_helpers.rb', line 40 def on_send(node) platform_check?(node) do add_offense(node, location: :expression, message: MSG, severity: :refactor) end end |