Class: RuboCop::Cop::Chef::CookbooksDependsOnSelf
- Inherits:
-
RuboCop::Cop
- Object
- RuboCop::Cop
- RuboCop::Cop::Chef::CookbooksDependsOnSelf
- Defined in:
- lib/rubocop/cop/chef/correctness/cb_depends_on_self.rb
Overview
Make sure a cookbook doesn’t depend on itself
Constant Summary collapse
- MSG =
'A cookbook cannot depend on itself'.freeze
Instance Method Summary collapse
Instance Method Details
#autocorrect(node) ⇒ Object
49 50 51 52 53 |
# File 'lib/rubocop/cop/chef/correctness/cb_depends_on_self.rb', line 49 def autocorrect(node) lambda do |corrector| corrector.remove(node.source_range) end end |
#on_send(node) ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/rubocop/cop/chef/correctness/cb_depends_on_self.rb', line 38 def on_send(node) cb_name?(node) do dependencies(processed_source.ast).each do |dep| if dep.arguments == node.arguments node = dep # set our dependency node as the node for autocorrecting later add_offense(node, location: dep.source_range, message: MSG, severity: :refactor) end end end end |