Class: Rigor::CLI::UnusedCommand
- Defined in:
- lib/rigor/cli/unused_command.rb
Overview
ADR-102 — executes rigor unused.
Reports project constants that nothing reachable references. It is a REPORT, never a diagnostic: the
measured precision of this signal is 7.0% on an adjudicated corpus target
(docs/notes/20260813-unused-constant-fp-baseline.md), so its output is a review queue, not a defect
list, and it never enters rigor check's stream at any severity (WD1). Exits 0 whatever it finds.
Constant Summary collapse
- USAGE =
"Usage: rigor unused [options] [paths]"- REFERENCE_GLOB =
WD7 — the REFERENCE corpus is wider than the ANALYSIS corpus.
.rakefiles sit insidepaths:and reference project constants, butPathExpansion::RUBY_GLOBnever reads them, which made them pure artifacts on two of three corpus targets. Harvesting references from a file is far cheaper than type-checking it, so the report takes the wider set. "**/*.{rb,rake}"- TEMPLATE_GLOB =
Templates and data files that carry class names as strings. A name here is NOT counted as a reference — a YAML value is far weaker evidence than a constant node, and treating it as proof would silently hide real dead code. It demotes the declaration to
cannot-decideinstead, with the file named, so the reader judges it (ADR-102 WD4). "**/*.{erb,haml,slim,yml,yaml,json}"
Instance Method Summary collapse
Methods inherited from Command
Constructor Details
This class inherits a constructor from Rigor::CLI::Command
Instance Method Details
#run ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/rigor/cli/unused_command.rb', line 40 def run = return CLI::EXIT_USAGE if == :usage_error configuration = Configuration.load(.fetch(:config)) paths = @argv.empty? ? configuration.paths : @argv declarations, references, dynamic_uses = scan(paths, configuration) references.concat(signature_references(configuration)) dynamic_uses.concat(template_mentions(declarations)) contribution = Analysis::Reachability::PluginRoots.collect(configuration: configuration) references.concat(plugin_references(contribution.references)) graph = Analysis::Reachability::Graph.new( declarations: declarations, references: references, dynamic_uses: dynamic_uses, root_fqns: root_fqns(declarations, .fetch(:entry_points)) + contribution.roots, foreign: foreign_predicate(configuration) ) emit(graph.report, , supply: root_supply(contribution.roots, declarations)) 0 end |