Class: Ducalis::UnlockedGem

Inherits:
RuboCop::Cop::Cop
  • Object
show all
Defined in:
lib/ducalis/cops/unlocked_gem.rb

Constant Summary collapse

OFFENSE =
<<-MESSAGE.gsub(/^ +\|\s/, '').strip
  | It's better to lock gem versions explicitly with pessimistic operator (~>).
MESSAGE

Instance Method Summary collapse

Instance Method Details

#investigate(processed_source) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/ducalis/cops/unlocked_gem.rb', line 11

def investigate(processed_source)
  return unless processed_source.ast

  gem_declarations(processed_source.ast).select do |node|
    _, _, gemname, _args = *node
    add_offense(node, :selector,
                format(OFFENSE, gem: gemname.loc.expression.source))
  end
end