Class: Ducalis::UncommentedGem

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

Constant Summary collapse

OFFENSE =
<<-MESSAGE.gsub(/^ +\|\s/, '').strip
  | Please, add comment why are you including non-realized gem version for %<gem>s.
MESSAGE
DETAILS =
<<-MESSAGE.gsub(/^ +\|\s/, '').strip
  | It will increase [bus-factor](<https://en.wikipedia.org/wiki/Bus_factor>).
MESSAGE
ALLOWED_KEYS =
%w[require group :require :group].freeze

Instance Method Summary collapse

Instance Method Details

#investigate(processed_source) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/ducalis/cops/uncommented_gem.rb', line 17

def investigate(processed_source)
  return unless processed_source.ast

  gem_declarations(processed_source.ast).select do |node|
    _, _, gemname, _args = *node
    next if commented?(processed_source, node)

    add_offense(node, :selector,
                format(OFFENSE, gem: gemname.loc.expression.source))
  end
end