ScanRunner class

Scans Dart files using saropa_lints rules without the plugin framework.

Issue cap: By default, ProgressTracker caps non-ERROR diagnostics at 500 for IDE Problems-tab performance. CLI tools that need complete output (accuracy report, audit) must pass disableIssueCap = true — otherwise rules silently appear "silent" after 500 issues are reached.

Constructors

ScanRunner({required String targetPath, List<String>? dartFiles, String? tier, Set<String>? enabledRuleNames, ScanMessageSink? messageSink, bool applyExclusionsToFileList = true, String? debugRule, bool excludeLightLane = false, bool bypassTierCap = false, RuleLane lane = RuleLane.full, bool laneStats = false, bool disableIssueCap = false, int? maxIssues, bool noExclude = false, List<String> excludeGlobs = const [], List<String> includeGlobs = const [], bool leaveStopSentinel = false, List<String>? preResolvedFiles})

Properties

applyExclusionsToFileList → bool
When dartFiles is provided, whether to apply the same exclusions as directory discovery (e.g. .g.dart, build/). Default true.
final
bypassTierCap → bool
Skips RuntimeTierCap.filterRuleSet() in _prepare(), allowing the full enabledRuleNames set to run uncapped. Used by the audit CLI which must exercise every rule regardless of the project's configured tier.
final
dartFiles → List<String>?
Optional explicit list of Dart files to scan. When null or empty, files are discovered under targetPath.
final
debugRule → String?
When set, emits per-node trace output for the named rule, showing type resolution details at each visited AST node.
final
disableIssueCap → bool
Disables the IDE Problems-tab issue cap (ProgressTracker._maxIssues) so every diagnostic reaches the listener. The 500-issue default is designed for live IDE analysis, not CLI batch scans where completeness matters (accuracy report, audit). Without this, non-ERROR diagnostics are silently dropped after 500 issues and rules appear "silent".
final
enabledRuleNames → Set<String>?
Optional explicit set of rule names to enable, bypassing both tier and the project config. Takes precedence over tier when both are set. Lets a caller exercise a rule set that no single tier expresses — notably the union of every defined rule including stylistic rules, which no tier (not even pedantic) contains. Used by the accuracy report so that stylistic-tier rules are actually run and not falsely reported as silent.
final
excludeLightLane → bool
Drops light-lane rules from the scan's rule set.
final
hashCode → int
The hash code for this object.
no setterinherited
lane → RuleLane
Which lane the scan should use. Defaults to RuleLane.full so every enabled rule fires. Set to RuleLane.light via --lane light to restrict the scan to the same cheap, resolution-free subset the analysis server runs in its default lane.
final
laneStats → bool
When true, prints how many rules are in the light lane vs full-only, making the lane gate's effect observable. Activated by --lane-stats.
final
lastParallelReport ↔ ParallelScanReport?
Report from the most recent runParallel (null before one ran).
getter/setter pair
leaveStopSentinel → bool
When true, a .saropa_stop sentinel is honored but NOT deleted. Worker isolates use this so every shard sees the stop request; the parent deletes the file once all workers have finished.
final
maxIssues → int?
Cap on reported non-ERROR diagnostics (errors are never capped). 0 = unlimited; null = leave the process-wide default (500, the IDE Problems-tab safeguard) unless disableIssueCap is set. The scan CLI and daemon pass 0 by default: a silent cap makes --fail-on-count thresholds and CI reports wrong.
final
messageSink → ScanMessageSink?
Optional sink for all messages. When null, messages go to stdout and progress to stderr.
final
noExclude → bool
When true, disables ALL hardcoded path exclusions (example/, build/, .dart_tool/, generated patterns, etc.) so every discovered .dart file is scanned. User-supplied --exclude-globs still apply.
final
ranRuleNames → Set<String>
Rules the last run actually instantiated (after tier, lane and config gating). The accepted-findings stale check uses it so an entry for a rule that did not run is never reported as stale.
no setter
registeredRuleNames → Set<String>
Rules that registered at least one visitor in the last run. Narrower than ranRuleNames: a rule whose registration threw or added no visitor is in the plan but never looks at a node.
no setter
ruleFileFailures → Set<String>
StaleIgnoreCoverage.failureKey pairs: a rule threw on that file and was disabled for the rest of its walk, so its silence there is not evidence.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
skippedFileCount → int
Number of files skipped for being outside the analysis context root.
no setter
targetPath → String
Project root: config is loaded from here and relative dartFiles are resolved against it.
final
tier → String?
Optional tier name (e.g. essential, recommended, pedantic). When set, the rule set starts from this tier's union; the project's diagnostics: section (if present) is still layered on top, so a rule the user explicitly disabled stays disabled even though the tier includes it.
final
walkedFiles → Set<String>
Files whose rule walk finished in the last run (paths as scanned). A file that failed to resolve, was outside the roots, or was never reached (stop sentinel, memory limit) is absent. Filled by the in-process paths only, which is what the stale-ignore scan uses.
no setter

Methods

countFilesToScan() → int
Number of files a scan would visit, without loading any rules. Lets the CLI size the worker pool before runParallel starts.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
openChunkScanner({required bool resolved, int slowFileMs = 3000, bool rescueExcluded = false}) → Future<ChunkScanner?>
Opens a reusable ChunkScanner: loads and registers the rules (and, when resolved, builds the analyzer context collection) ONCE, then scans any number of file chunks against them. Used by worker isolates and by the in-process fallback of runParallel. Returns null when there is nothing to run (no rules enabled / unusable config).
run() → List<ScanDiagnostic>?
Runs the default syntactic scan and returns all diagnostics found.
runParallel(int jobs, {bool resolve = false, ScanParallelConfig config = const ScanParallelConfig()}) → Future<List<ScanDiagnostic>?>
Scans with jobs worker isolates (see parallel_scan_engine.dart): a chunk work queue with a memory/pressure watchdog, per-chunk timeouts and progress reporting. Output is identical for any worker count.
runResolved() → Future<List<ScanDiagnostic>?>
Runs the scan with full type/element resolution and returns all diagnostics found. Returns null under the same no-config / unknown-tier conditions as run.
runResolvedWithCollection(AnalysisContextCollection collection) → Future<List<ScanDiagnostic>?>
Runs the resolved scan for dartFiles against an already-built collection instead of creating a new one.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

buildProjectCollection(String projectRoot) → AnalysisContextCollection
Builds an AnalysisContextCollection rooted at projectRoot for a long-lived caller (the scan daemon) to hold and reuse across many runResolvedWithCollection calls. This is the expensive step runResolved otherwise repeats on every invocation.
discoverDartFiles(String directory, {List<String> excludeGlobs = const [], List<String> includeGlobs = const []}) → List<String>
Public wrapper around _findDartFiles for callers that need the project's discovered file list up front (e.g. the scan daemon's listFiles request, which the IDE baseline scan uses to build chunked batches before issuing per-chunk resolved scans).
matchesAnyGlob(String path, List<String> globs, String root) → bool
Whether path matches one of globs, with the same matching as --exclude-globs (as given, absolute, or relative to root). For callers that pick files outside discovery but must still honor the user's globs.