Skip to content

fix(rules): treat every module of a binary-only package as program code for bug-println - #707

Merged
ajianaz merged 1 commit into
developfrom
fix/682-binary-crate-println
Oct 27, 2026
Merged

ajianaz merged 1 commit into
developfrom
fix/682-binary-crate-println

Conversation

@ajianaz

@ajianaz ajianaz commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator

What

bug-println now exempts every module of a binary-only package (a src/main.rs and no src/lib.rs in the same package), not just main.rs, src/bin/, examples/ and benches/. A library package, or one that has both main.rs and lib.rs, keeps the rule.

The package is looked up relative to the scan root (cora scan --path, the MCP scan tools) or, for a diff review, the git toplevel, never the process working directory (found by the pre-commit review of this change).

Why

In a binary crate stdout is the program's interface, yet its non-entry modules still produced 64 bug-println hits on a real workspace, while a core crate must keep guarding against writing to stdout. The eprintln! and expect("...") halves of #682 shipped earlier; this is the remaining part. Closes #682.

Testing

  • Unit test with a temporary package layout: binary-only module exempt, library module flagged, lib+bin package keeps the rule, entry points and examples/ exempt, unknown package flagged.
  • End-to-end tests (tests/binary_crate_println.rs): println! in crates/cli/src/commands.rs is not reported, in crates/core/src/lib.rs it is, eprintln! never is; the same holds for cora scan --path proj run from the parent directory.
  • fmt, clippy -D warnings and the full suite pass.

…de for bug-println (#682)

Signed-off-by: ajianaz <ajianaz@users.noreply.github.com>
@ajianaz
ajianaz merged commit aed73b6 into develop Oct 27, 2026
13 checks passed
ajianaz added a commit that referenced this pull request Oct 27, 2026
…de for bug-println (#707)

## What

`bug-println` now exempts every module of a binary-only package (a
`src/main.rs` and no `src/lib.rs` in the same package), not just
`main.rs`, `src/bin/`, `examples/` and `benches/`. A library package, or
one that has both `main.rs` and `lib.rs`, keeps the rule.

The package is looked up relative to the scan root (`cora scan --path`,
the MCP scan tools) or, for a diff review, the git toplevel, never the
process working directory (found by the pre-commit review of this
change).

## Why

In a binary crate stdout is the program's interface, yet its non-entry
modules still produced 64 `bug-println` hits on a real workspace, while
a core crate must keep guarding against writing to stdout. The
`eprintln!` and `expect("...")` halves of #682 shipped earlier; this is
the remaining part. Closes #682.

## Testing

- Unit test with a temporary package layout: binary-only module exempt,
library module flagged, lib+bin package keeps the rule, entry points and
`examples/` exempt, unknown package flagged.
- End-to-end tests (tests/binary_crate_println.rs): `println!` in
`crates/cli/src/commands.rs` is not reported, in
`crates/core/src/lib.rs` it is, `eprintln!` never is; the same holds for
`cora scan --path proj` run from the parent directory.
- fmt, clippy -D warnings and the full suite pass.

Signed-off-by: ajianaz <ajianaz@users.noreply.github.com>
Co-authored-by: ajianaz <ajianaz@users.noreply.github.com>
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.

feat(rules): bug-println flags eprintln!; bug-expect flags expect("<invariant>") like a bare unwrap()

1 participant