Class: RuboCop::Cop::Chef::Modernize::DependsOnLocaleCookbook

Inherits:
Base
  • Object
show all
Extended by:
AutoCorrector, TargetChefVersion
Includes:
RangeHelp
Defined in:
lib/rubocop/cop/chef/modernize/depends_locale_cookbook.rb

Overview

Don't depend on the locale cookbook made obsolete by Chef Infra Client 14.5. The locale resource is now included in Chef Infra Client itself.

Examples:


# bad
depends 'locale'

# good
# the resource ships in Chef Infra Client 14.5+, so use it without a depends
locale 'set locale' do
  lang 'en_us.UTF-8'
end

Constant Summary collapse

MSG =
"Don't depend on the locale cookbook made obsolete by Chef Infra Client 14.5. The locale resource is now included in Chef Infra Client itself."
RESTRICT_ON_SEND =
[:depends].freeze

Instance Method Summary collapse

Methods included from TargetChefVersion

minimum_target_chef_version, required_minimum_chef_version, support_target_chef_version?

Methods inherited from Base

#target_chef_version

Instance Method Details

#on_send(node) ⇒ Object



49
50
51
52
53
54
55
# File 'lib/rubocop/cop/chef/modernize/depends_locale_cookbook.rb', line 49

def on_send(node)
  legacy_depends?(node) do
    add_offense(node, severity: :refactor) do |corrector|
      corrector.remove(range_with_surrounding_space(range: node.loc.expression, side: :left))
    end
  end
end