diff --git a/lib/rubocop/cop/chef/style/use_platform_helpers.rb b/lib/rubocop/cop/chef/style/use_platform_helpers.rb index 062c062e3..c295498b9 100644 --- a/lib/rubocop/cop/chef/style/use_platform_helpers.rb +++ b/lib/rubocop/cop/chef/style/use_platform_helpers.rb @@ -38,18 +38,16 @@ class UsePlatformHelpers < Cop PATTERN def on_send(node) - platform_check?(node) do |type, plat| - # set these so we can use them in the auto_correct method - @type = type - @plat = plat - + platform_check?(node) do add_offense(node, location: :expression, message: MSG, severity: :refactor) end end def autocorrect(node) lambda do |corrector| - corrector.replace(node.loc.expression, "#{@type.value}?('#{@plat.value}')") + platform_check?(node) do |type, plat| + corrector.replace(node.loc.expression, "#{type.value}?('#{plat.value}')") + end end end end