Class: RuboCop::Cop::Cobra::DependencyVersion

Inherits:
RuboCop::Cop::Cop
  • Object
show all
Extended by:
NodePattern::Macros
Defined in:
lib/rubocop/cop/cobra/dependency_version.rb

Constant Summary collapse

MSG =
"External component dependencies should be declared with a version"

Instance Method Summary collapse

Instance Method Details

#investigate(processed_source) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rubocop/cop/cobra/dependency_version.rb', line 11

def investigate(processed_source)
  return if processed_source.blank?

  path = processed_source.file_path
  return unless path.end_with?(".gemspec")

  dependency_declarations(processed_source.ast).each do |dep|
    next if declares_version?(dep)

    add_offense(dep, message: MSG)
  end
end