Class: GemXray::Analyzers::UnusedAnalyzer

Inherits:
Base
  • Object
show all
Defined in:
lib/gemxray/analyzers/unused_analyzer.rb

Constant Summary collapse

KNOWN_DEV_TOOLS =
%w[
  brakeman bundler-audit byebug capistrano capistrano-rails codecov
  debug factory_bot factory_bot_rails faker overcommit pry pry-rails
  rake rspec rspec-core rspec-rails rubocop rubocop-performance
  rubocop-rails rubocop-rspec simplecov
].freeze

Constants inherited from Base

Base::AUTOLOADED_GEMS

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from GemXray::Analyzers::Base

Instance Method Details

#analyze(gems) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/gemxray/analyzers/unused_analyzer.rb', line 13

def analyze(gems)
  gems.filter_map do |gem_entry|
    next if skipped?(gem_entry)
    next if KNOWN_DEV_TOOLS.include?(gem_entry.name)
    next if gem_used?(gem_entry)

    detail =
      if gem_entry.development_group?
        "no usage found in code (group :development / :test)"
      else
        "no require or constant reference was found in the scanned code"
      end

    build_result(
      gem_entry: gem_entry,
      type: :unused,
      severity: gem_entry.development_group? ? :warning : :danger,
      detail: detail
    )
  end
end