class RuboCop::Cop::Chef::Modernize::PowerShellGuardInterpreter
PowerShell is already set as the default guard interpreter for ‘powershell_script` and `batch` resources in Chef
Infra Client 13 and later and does not need to be specified.
@example
### incorrect powershell_script 'Create Directory' do code "New-Item -ItemType Directory -Force -Path C:\mydir" guard_interpreter :powershell_script end batch 'Create Directory' do code "mkdir C:\mydir" guard_interpreter :powershell_script end ### correct powershell_script 'Create Directory' do code "New-Item -ItemType Directory -Force -Path C:\mydir" end batch 'Create Directory' do code "mkdir C:\mydir" end
Constants
- MSG
Public Instance Methods
Source
# File lib/rubocop/cop/chef/modernize/powershell_guard_interpreter.rb, line 56 def on_block(node) match_property_in_resource?(%i(powershell_script batch), 'guard_interpreter', node) do |interpreter| return unless interpreter.arguments.first.source == ':powershell_script' add_offense(interpreter, severity: :refactor) do |corrector| corrector.remove(range_with_surrounding_space(range: interpreter.loc.expression, side: :left)) end end end