Skip to content

lint: weak asserts outside test files, and a waiver date token - #687

Merged
reardencode merged 2 commits into
reardencode:masterfrom
Hero-Gamer:add/ast-grep-enforce-mutation-policy
Sep 23, 2026
Merged

reardencode merged 2 commits into
reardencode:masterfrom
Hero-Gamer:add/ast-grep-enforce-mutation-policy

Conversation

@Hero-Gamer

@Hero-Gamer Hero-Gamer commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Rebased onto current master.

What this adds

Two ast-grep rules, run by the existing ast-grep job. They do not scan the unit-test files where mutant misses usually live.

  • weak-assert.yml flags bare is_ok / is_err / matches!(Ok(_)) / matches!(Err(_)) (and the assert_eq!(…, true) forms) in Rust that is not a test file.

    • Not scanned: *tests*.rs, tests/, benches/.
    • Scanned: other .rs files, including a #[cfg(test)] module inside them. ast-grep has no cfg.
    • tip_accept.rs and script_pool.rs are excluded entirely. The rule does not enforce an expiry on those exclusions.
    • This is not a mutant-killer gate.
  • waiver-expiry.yml requires a MUTANT-WAIVER comment in a scanned file to contain an expires YYYY-MM-DD token. The date is not compared to today. Comments in *tests*.rs and tests/ are not scanned.

Compliance

  • Fixtures: bad patterns are flagged, good patterns pass.
  • No new CI job.

@Hero-Gamer
Hero-Gamer force-pushed the add/ast-grep-enforce-mutation-policy branch from 26e1b83 to 3620b68 Compare September 22, 2026 23:49
@Hero-Gamer Hero-Gamer changed the title Add ast-grep: Tier1 weak-assert rules + MUTANT-WAIVER expiry — aligned with TESTING.md Add ast-grep: Enforce Tier1 exact assertions + MUTANT-WAIVER expiry — apply to src/ test blocks Sep 22, 2026
@Hero-Gamer
Hero-Gamer force-pushed the add/ast-grep-enforce-mutation-policy branch from 3620b68 to a2a1dc8 Compare September 23, 2026 00:41
@Hero-Gamer Hero-Gamer changed the title Add ast-grep: Enforce Tier1 exact assertions + MUTANT-WAIVER expiry — apply to src/ test blocks Add ast-grep: Enforce exact error-variant assertions + MUTANT-WAIVER expiry Sep 23, 2026
@Hero-Gamer
Hero-Gamer force-pushed the add/ast-grep-enforce-mutation-policy branch from a2a1dc8 to d714fe5 Compare September 23, 2026 01:04
Hero-Gamer and others added 2 commits September 23, 2026 12:01
…expiry

- weak-assert.yml: Flag assertions that check only is_err/is_ok rather than
  the specific error variant. Applies to src/ including #[cfg(test)] blocks.
- waiver-expiry.yml: Require YYYY-MM-DD expiry date on all MUTANT-WAIVER comments
- Explicit ignores: separate test dirs, benches, core vector fixture files
- Exempt 2 pre-existing panic-detection assertions with expiry 2026-12-31
- Zero hits on master → CI-safe
- Per code-shape.md: structural lint only, not a second clippy
weak-assert does not see *tests*.rs, tests/, or benches/, and the two
excluded src files have no expiry check. A MUTANT-WAIVER date token is
required only in scanned files, and the date is not compared to today.
@rearden-grok
rearden-grok Bot force-pushed the add/ast-grep-enforce-mutation-policy branch from d714fe5 to 5e5cb2f Compare September 23, 2026 19:01
@rearden-grok rearden-grok Bot changed the title Add ast-grep: Enforce exact error-variant assertions + MUTANT-WAIVER expiry lint: weak asserts outside test files, and a waiver date token Sep 23, 2026
@reardencode
reardencode merged commit 38b96f2 into reardencode:master Sep 23, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants