Class: RuboCop::Cop::Chef::Effortless::CookbookUsesEnvironments

Inherits:
Base
  • Object
show all
Defined in:
lib/rubocop/cop/chef/effortless/node_environment.rb

Overview

Neither Policyfiles or Effortless Infra which is based on Policyfiles supports Chef Environments

Examples:


### incorrect
node.environment == "production"
node.chef_environment == "production"

Constant Summary collapse

MSG =
'Cookbook uses environments, which cannot be used in Policyfiles or Effortless Infra'
RESTRICT_ON_SEND =
[:environment, :chef_environment].freeze

Instance Method Summary collapse

Methods inherited from Base

#target_chef_version

Instance Method Details

#on_send(node) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/rubocop/cop/chef/effortless/node_environment.rb', line 34

def on_send(node)
  if node.receiver &&
     node.receiver.send_type? &&
     node.receiver.method?(:node)
    add_offense(node, severity: :refactor)
  end
end