Skip to content

Broaden static-regex lint guard to cover supported lazy wrappers #410

Description

@coderabbitai

Summary

Broaden Makefile's check-static-regexes scan so hand-rolled static regex declarations cannot bypass the repository's lazy_regex! convention by using lazy-wrapper constructors other than std::sync::LazyLock::new.

Rationale

The current pattern at Makefile Line 46 only detects LazyLock::new(... Regex::new(...)). A declaration using once_cell::sync::Lazy::new(|| Regex::new(...)) is not detected, allowing a prohibited static-regex construction to pass make lint.

Affected area

  • Makefile: check-static-regexes
  • Add focused regression coverage or fixtures for the lint pattern.

Required changes

  1. Extend the scan to detect direct and fully qualified supported lazy-wrapper constructors, including once_cell::sync::Lazy::new, in addition to LazyLock::new.
  2. Define the supported wrapper forms in the regression coverage so each form is rejected when it directly wraps Regex::new.
  3. Preserve the existing behaviour:
    • a matching prohibited declaration fails with the existing static-regex diagnostic;
    • no matches succeed;
    • ripgrep scan failures propagate with the existing error handling.
  4. Keep the change minimal and retain lazy_regex! as the sole sanctioned idiom for static regex declarations.
  5. Run every applicable formatting, lint, and test gate before closing the issue.

Acceptance criteria

  • A hand-rolled LazyLock::new(|| Regex::new(...)) static regex is rejected.
  • A hand-rolled once_cell::sync::Lazy::new(|| Regex::new(...)) static regex is rejected, including qualified constructor spelling.
  • Regression coverage exercises every lazy-wrapper constructor form supported by the guard.
  • make lint retains its existing result and diagnostic behaviour for clean scans, prohibited declarations, and ripgrep failures.
  • All applicable commit gates pass.

Backlinks

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinglowAin't annoying anyone but the QA departmenttesting

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions