Class: Reviewer::Doctor::DiscoveryCheck

Inherits:
Object
  • Object
show all
Defined in:
lib/reviewer/doctor/discovery_check.rb

Overview

Reports known tools observed in the project but absent from valid configuration.

Constant Summary collapse

SHELL_OPERATORS =
/[;&|\r\n]/

Instance Method Summary collapse

Constructor Details

#initialize(report, project_dir, configured_keys:) ⇒ DiscoveryCheck

Returns a new instance of DiscoveryCheck.



12
13
14
15
16
# File 'lib/reviewer/doctor/discovery_check.rb', line 12

def initialize(report, project_dir, configured_keys:)
  @report = report
  @project_dir = Pathname(project_dir)
  @configured_keys = configured_keys.map(&:to_sym)
end

Instance Method Details

#checkObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/reviewer/doctor/discovery_check.rb', line 18

def check
  observations = detector_observations
  package_script_observations.each do |key, observation|
    observations[key] << observation
  end

  Setup::Catalog.all.each_key do |key|
    next if @configured_keys.include?(key) || observations[key].empty?

    @report.add_discovery(
      key: key,
      name: Setup::Catalog.config_for(key).fetch(:name),
      observations: observations[key].uniq(&:to_h)
    )
  end
end