Class: RuboCop::Cop::Chef::Correctness::MetadataMalformedDepends

Inherits:
Base
  • Object
show all
Extended by:
AutoCorrector
Defined in:
lib/rubocop/cop/chef/correctness/metadata_malformed_version.rb

Overview

metadata.rb cookbook dependencies and version constraints should be comma separated.

Examples:


### incorrect
depends 'some_awesome_cookbook' '= 4.5.5'
depends 'some_other_cool_cookbook' '< 8.0'

### correct
depends 'some_awesome_cookbook', '= 4.5.5'
depends 'some_other_cool_cookbook', '< 8.0'

Constant Summary collapse

RESTRICT_ON_SEND =
[:depends].freeze
MSG =
'metadata.rb cookbook dependencies and version constraints should be comma separated'

Instance Method Summary collapse

Methods inherited from Base

#target_chef_version

Instance Method Details

#on_send(node) ⇒ Object



47
48
49
50
51
52
53
# File 'lib/rubocop/cop/chef/correctness/metadata_malformed_version.rb', line 47

def on_send(node)
  depends_without_comma?(node) do |cb, ver|
    add_offense(node, severity: :refactor) do |corrector|
      corrector.replace(node, "depends '#{cb.value}', '#{ver.value}'")
    end
  end
end