Skip to content

feat(enrichment): magic-number heuristic analyzer #2018

Description

@JSONbored

New REES local analyzer that flags unexplained numeric literals newly added in non-test source (excluding 0/1/-1, array indices, and obvious enum-like assignments) that would be clearer as a named constant. Precision-first heuristic, pure compute, no network.

Deliverables

  • Add MagicNumberFinding ({ file, line, value: string }) + magicNumber? key to review-enrichment/src/types.ts
  • Create review-enrichment/src/analyzers/magic-number.ts: scan added lines for bare numeric literals in expressions; allowlist trivial values (0,1,-1,2,100,1000, powers of ten), skip const NAME = <n> declarations, skip test files; cap with maxFindings
  • Register a local descriptor (category 'quality', cost 'local', requires ['files']) with inline render() in review-enrichment/src/analyzers/registry.ts
  • Add review-enrichment/test/magic-number.test.ts covering allowlist suppression, named-const suppression, test-file skip, detection of a genuine magic number, and the cap

References

  • review-enrichment/src/analyzers/redos.ts (precision-first local heuristic template)
  • review-enrichment/src/analyzers/actions-pin.ts (hunk line-number tracking)
  • review-enrichment/src/analyzers/registry.ts:158-175

Part of #1499.


size: S · gittensor:feature

Metadata

Metadata

Assignees

No one assigned

    Labels

    gittensor:featureGittensor-scored feature linked to a feature issue — scores a 0.25x multiplier.help wantedExtra attention is needed

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions