Class: RuboCop::Cop::Chef::ChefModernize::PowerShellGuardInterpreter
- Inherits:
-
RuboCop::Cop
- Object
- RuboCop::Cop
- RuboCop::Cop::Chef::ChefModernize::PowerShellGuardInterpreter
- Includes:
- RangeHelp, RuboCop::Chef::CookbookHelpers
- Defined in:
- lib/rubocop/cop/chef/modernize/powershell_guard_interpreter.rb
Overview
PowerShell is already set as the default guard interpreter for powershell_script resources in Chef Infra Client 13 and later and does not need to be specified.
Constant Summary collapse
- MSG =
'PowerShell is already set as the default guard interpreter for powershell_script resources in Chef Infra Client 13 and later and does not need to be specified.'.freeze
Instance Method Summary collapse
Methods included from RuboCop::Chef::CookbookHelpers
#match_property_in_resource?, #match_resource_type?, #method_arg_ast_to_string, #resource_block_name_if_string
Instance Method Details
#autocorrect(node) ⇒ Object
50 51 52 53 54 |
# File 'lib/rubocop/cop/chef/modernize/powershell_guard_interpreter.rb', line 50 def autocorrect(node) lambda do |corrector| corrector.remove(range_with_surrounding_space(range: node.loc.expression, side: :left)) end end |
#on_block(node) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/rubocop/cop/chef/modernize/powershell_guard_interpreter.rb', line 42 def on_block(node) match_property_in_resource?(:powershell_script, 'guard_interpreter', node) do |interpreter| if interpreter.arguments.first.source == ':powershell_script' add_offense(interpreter, location: :expression, message: MSG, severity: :refactor) end end end |