Class: Audition::Static::Analyzer
- Inherits:
-
Object
- Object
- Audition::Static::Analyzer
- Defined in:
- lib/audition/static/analyzer.rb
Overview
Runs the per-file Prism checks over sources or paths.
Constant Summary collapse
- PARALLEL_THRESHOLD =
16
Instance Method Summary collapse
- #analyze_path(path) ⇒ Array<Finding>
-
#analyze_paths(paths, workers: default_workers, threshold: PARALLEL_THRESHOLD) ⇒ Array<Finding>
Scans files across Ractors when there are enough of them to be worth the spawn cost.
- #analyze_source(source, path:) ⇒ Array<Finding>
-
#initialize(checks: Checks.all) ⇒ Analyzer
constructor
A new instance of Analyzer.
Constructor Details
Instance Method Details
#analyze_path(path) ⇒ Array<Finding>
24 25 26 |
# File 'lib/audition/static/analyzer.rb', line 24 def analyze_path(path) analyze_file(SourceFile.read(path)) end |
#analyze_paths(paths, workers: default_workers, threshold: PARALLEL_THRESHOLD) ⇒ Array<Finding>
Scans files across Ractors when there are enough of them to
be worth the spawn cost. Checks are plain shareable classes
with deeply frozen catalogs, findings copy back through
Ractor#value, and anything unexpected falls back to the
serial path.
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/audition/static/analyzer.rb', line 42 def analyze_paths(paths, workers: default_workers, threshold: PARALLEL_THRESHOLD) if paths.size < threshold || workers <= 1 return paths.flat_map { |path| analyze_path(path) } end parallel_analyze(paths, workers) rescue Ractor::Error paths.flat_map { |path| analyze_path(path) } end |
#analyze_source(source, path:) ⇒ Array<Finding>
18 19 20 |
# File 'lib/audition/static/analyzer.rb', line 18 def analyze_source(source, path:) analyze_file(SourceFile.new(source: source, path: path)) end |