Skip to content

Exclude tests and benches from panic-surface analysis (false-positive class) #171

Description

@hyperpolymath

Reported by the owner: panic-attack does good work on real code, but is riddled with false positives — and a large share of them are not about production code at all, but about the tests and benchmarks themselves.

That is a category error rather than a tuning problem: test code is supposed to panic. assert!, assert_eq!, unwrap() on known-good fixtures, expect() with a deliberate message, and #[should_panic] are all correct, idiomatic test constructs. A panic-surface scanner that does not exclude test targets will fire on healthy code by design, and the more thorough the test suite, the noisier it gets.

Why this matters beyond noise

A 2026-08-05 estate-wide CI census measured panic-attack reporting in 90 repos and required in 2. It was initially a strong candidate for promotion to a blocking gate — it does fail (87 pass / 2 fail), which is more than most checks in the estate manage.

That promotion has been withdrawn because of this issue, and the reasoning is worth recording:

Falsifiability is necessary but not sufficient. A check that fires only on false positives passes the "has it ever failed?" test while being worse than useless as a gate — it blocks correct work and trains people to override, which destroys the distinction between "this is fine" and "this is broken".

So panic-attack stays advisory until its precision is fixed, at which point it is a genuinely good gate candidate: fast, deterministic, and catching a real defect class.

Suggested scope

  • Exclude #[cfg(test)] modules and functions.
  • Exclude the tests/ and benches/ directories (Cargo's integration-test and benchmark targets).
  • Exclude #[should_panic] functions specifically, wherever they live.
  • Consider excluding build.rs, where a panic is a legitimate hard-stop.
  • If any of these are wanted, make them opt-in flags rather than the default — the default should be production code only.

Acceptance

A repo with a thorough panicking test suite and clean production code should report zero findings. That is the check that would have caught this class.

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions