Class: RuboCop::Cop::Chef::Correctness::ChefApplicationFatal

Inherits:
Base
  • Object
show all
Extended by:
AutoCorrector
Defined in:
lib/rubocop/cop/chef/correctness/chef_application_fatal.rb

Overview

Use ‘raise` to force Chef Infra Client to fail instead of using `Chef::Application.fatal`, which masks the full stack trace of the failure and makes debugging difficult.

Examples:


### incorrect
Chef::Application.fatal!('Something horrible happened!')

### correct
raise "Something horrible happened!"

Constant Summary collapse

MSG =
'Use raise to force Chef Infra Client to fail instead of using Chef::Application.fatal'
RESTRICT_ON_SEND =
[:fatal!].freeze

Instance Method Summary collapse

Methods inherited from Base

#target_chef_version

Instance Method Details

#on_send(node) ⇒ Object



45
46
47
48
49
50
51
# File 'lib/rubocop/cop/chef/correctness/chef_application_fatal.rb', line 45

def on_send(node)
  application_fatal?(node) do |val|
    add_offense(node, severity: :refactor) do |corrector|
      corrector.replace(node, "raise(#{val.source})")
    end
  end
end