Class: RuboCop::Cop::Chef::Correctness::PowershellFileExists
- Defined in:
- lib/rubocop/cop/chef/correctness/powershell_file_exists.rb
Overview
Use Ruby’s built-in ‘File.exist?(’C:somefile’)‘ method instead of executing PowerShell’s ‘Test-Path` cmdlet, which takes longer to load.
Constant Summary collapse
- RESTRICT_ON_SEND =
[:powershell_out, :powershell_out!].freeze
- MSG =
"Use Ruby's built-in `File.exist?('C:\\somefile')` method instead of executing PowerShell's `Test-Path` cmdlet, which takes longer to load."
Instance Method Summary collapse
Methods inherited from Base
Instance Method Details
#on_send(node) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/rubocop/cop/chef/correctness/powershell_file_exists.rb', line 40 def on_send(node) powershell_out_exists?(node) do |exists_string| return unless exists_string.match?(/^Test-Path/) add_offense(node, severity: :refactor) end end |