Class: RuboCop::Cop::Chef::Effortless::ChefVaultUsed

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

Overview

Chef Vault is not supported in the Effortless pattern, so usage of Chef Vault must be shifted to another secrets management solution before leveraging the Effortless pattern.

Examples:


### incorrect
require 'chef-vault'

### incorrect
ChefVault::Item

### incorrect
include_recipe 'chef-vault'

### incorrect
chef_gem 'chef-vault'

### incorrect
chef_vault_item_for_environment(arg, arg1)

### incorrect
chef_vault_item(arg, arg1)

Constant Summary collapse

MSG =
'Chef Vault usage is not supported in the Effortless pattern'
RESTRICT_ON_SEND =
[:chef_vault_item,
:chef_vault_item_for_environment,
:include_recipe,
:require,
:chef_gem].freeze

Instance Method Summary collapse

Methods inherited from Base

#target_chef_version

Instance Method Details

#on_const(node) ⇒ Object



78
79
80
81
82
# File 'lib/rubocop/cop/chef/effortless/chef_vault_used.rb', line 78

def on_const(node)
  vault_const?(node) do
    add_offense(node.loc.expression, severity: :refactor)
  end
end

#on_send(node) ⇒ Object



71
72
73
74
75
76
# File 'lib/rubocop/cop/chef/effortless/chef_vault_used.rb', line 71

def on_send(node)
  return unless require?(node) ||
                chef_vault_item_for_environment?(node) ||
                chef_vault_item?(node)
  add_offense(node.loc.expression, severity: :refactor)
end