Class: RuboCop::Cop::Chef::Modernize::ShellOutToChocolatey
- Includes:
- RuboCop::Chef::CookbookHelpers
- Defined in:
- lib/rubocop/cop/chef/modernize/shellouts_to_chocolatey.rb
Overview
Use the Chocolatey resources built into Chef Infra Client instead of shelling out to the choco command
Constant Summary collapse
- MSG =
'Use the Chocolatey resources built into Chef Infra Client instead of shelling out to the choco command'
Instance Method Summary collapse
Methods included from RuboCop::Chef::CookbookHelpers
#each_action_symbol, #match_property_in_resource?, #match_resource_type?, #method_arg_ast_to_string, #resource_block_name_if_string
Methods inherited from Base
Instance Method Details
#on_block(node) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/rubocop/cop/chef/modernize/shellouts_to_chocolatey.rb', line 52 def on_block(node) match_property_in_resource?(:powershell_script, 'code', node) do |code_property| property_data = method_arg_ast_to_string(code_property) next unless property_data && property_data.match?(/^choco /i) add_offense(node, severity: :refactor) end match_property_in_resource?(:execute, 'command', node) do |code_property| property_data = method_arg_ast_to_string(code_property) next unless property_data && property_data.match?(/^choco /i) add_offense(node, severity: :refactor) end end |