Class: RuboCop::Cop::Chef::Correctness::ConditionalRubyShellout
- Extended by:
- AutoCorrector
- Includes:
- RuboCop::Chef::CookbookHelpers
- Defined in:
- lib/rubocop/cop/chef/correctness/conditional_ruby_shellout.rb
Overview
Don’t use Ruby to shellout in a ‘only_if` / `not_if` conditional. Any string value used in an `only_if` / `not_if` is executed in your system’s shell and the return code of the command is the result for the ‘not_if` / `only_if` determination.
Constant Summary collapse
- MSG =
"Don't use Ruby to shellout in an only_if / not_if conditional when you can shellout directly by wrapping the command in quotes."
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
Methods inherited from Base
Instance Method Details
#on_block(node) ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/rubocop/cop/chef/correctness/conditional_ruby_shellout.rb', line 58 def on_block(node) conditional_shellout?(node) do |type, val| add_offense(node, severity: :refactor) do |corrector| corrector.replace(node, "#{type} #{val.source}") end end end |