class RuboCop::Cop::Chef::RedundantCode::DoubleCompileTime

If a resource includes the ‘compile_time` property there’s no need to also use ‘.run_action(:some_action)` on the resource block

@example

#### incorrect
chef_gem 'deep_merge' do
  action :nothing
  compile_time true
end.run_action(:install)

#### correct
chef_gem 'deep_merge' do
  action :install
  compile_time true
end

Constants

MSG
RESTRICT_ON_SEND

Public Instance Methods

on_send(node) click to toggle source
# File lib/rubocop/cop/chef/redundant/double_compile_time.rb, line 57
def on_send(node)
  compile_time_and_run_action?(node) do |resource, action, run_action|
    add_offense(node.loc.selector, severity: :refactor) do |corrector|
      corrector.replace(node, resource.source.gsub(action.to_s, run_action.to_s))
    end
  end
end