Class: RailsDoctor::Scanner
- Inherits:
-
Object
- Object
- RailsDoctor::Scanner
- Defined in:
- lib/rails_doctor/scanner.rb
Constant Summary collapse
- ADAPTERS =
{ "rubocop" => Adapters::Rubocop, "brakeman" => Adapters::Brakeman, "bundler_audit" => Adapters::BundlerAudit, "zeitwerk" => Adapters::Zeitwerk, "reek" => Adapters::Reek, "strong_migrations" => Adapters::StrongMigrations, "flog" => Adapters::Flog, "flay" => Adapters::Flay, "dependency_freshness" => Adapters::DependencyFreshness, "test_runner" => Adapters::TestRunner, "test_coverage" => Adapters::TestCoverage, "rails_checks" => Checks::RailsChecks }.freeze
Instance Method Summary collapse
-
#initialize(project_root:, config:, env: ENV) ⇒ Scanner
constructor
A new instance of Scanner.
- #run(profile: "recommended", changed_only: false, base_ref: nil) ⇒ Object
Constructor Details
#initialize(project_root:, config:, env: ENV) ⇒ Scanner
Returns a new instance of Scanner.
36 37 38 39 40 41 |
# File 'lib/rails_doctor/scanner.rb', line 36 def initialize(project_root:, config:, env: ENV) @project_root = File.(project_root) @config = config @runner = CommandRunner.new(project_root: @project_root, env: env) @project = Project.new(root: @project_root, runner: @runner) end |
Instance Method Details
#run(profile: "recommended", changed_only: false, base_ref: nil) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/rails_doctor/scanner.rb', line 43 def run(profile: "recommended", changed_only: false, base_ref: nil) effective_base_ref = base_ref || @config.data.fetch("git", {})["base_ref"] changed_files = @project.changed_files(base_ref: effective_base_ref) result = ScanResult.new( project_root: @project_root, profile: profile, metadata: (changed_files: changed_files, base_ref: effective_base_ref) ) result.findings.concat(compatibility_findings) @config.adapters_for(profile).each do |name| adapter_class = ADAPTERS.fetch(name) { raise Error, "Unknown adapter #{name}" } adapter = adapter_class.new( project: @project, config: @config, runner: @runner, profile: profile, changed_files: changed_files ) run_adapter(adapter, result) end result.findings = deduplicate(result.findings) result.findings = filter_changed(result.findings, changed_files) if changed_only scorer = Scorer.new(project: @project, config: @config, changed_files: changed_files) result.hotspots = scorer.hotspots(result.findings) result.score = scorer.score(result) result.finish! end |