Class: RuboCop::Cop::Chef::ChefDeprecations::ResourceOverridesProvidesMethod
- Inherits:
-
RuboCop::Cop
- Object
- RuboCop::Cop
- RuboCop::Cop::Chef::ChefDeprecations::ResourceOverridesProvidesMethod
- Defined in:
- lib/rubocop/cop/chef/deprecation/resource_overrides_provides_method.rb
Overview
Some providers in resources override the provides? method, used to check whether they are a valid provider on the current platform. In Chef Infra Client 13, this will cause an error. Instead use ‘provides :SOME_PROVIDER_NAME` to register the provider.
Constant Summary collapse
- MSG =
"Don't override the provides? method in a resource provider. Use provides :SOME_PROVIDER_NAME instead. This will cause failures in Chef Infra Client 13 and later.".freeze
Instance Method Summary collapse
Instance Method Details
#on_def(node) ⇒ Object
38 39 40 41 42 |
# File 'lib/rubocop/cop/chef/deprecation/resource_overrides_provides_method.rb', line 38 def on_def(node) if node.method_name == :provides? add_offense(node, location: :expression, message: MSG, severity: :refactor) if provides(processed_source.ast).count == 0 end end |