Repository navigation
fix(rules): treat every module of a binary-only package as program code for bug-println - #707
Merged
Merged
Conversation
…de for bug-println (#682) Signed-off-by: ajianaz <ajianaz@users.noreply.github.com>
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
bug-printlnnow exempts every module of a binary-only package (asrc/main.rsand nosrc/lib.rsin the same package), not justmain.rs,src/bin/,examples/andbenches/. A library package, or one that has bothmain.rsandlib.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-printlnhits on a real workspace, while a core crate must keep guarding against writing to stdout. Theeprintln!andexpect("...")halves of #682 shipped earlier; this is the remaining part. Closes #682.Testing
examples/exempt, unknown package flagged.println!incrates/cli/src/commands.rsis not reported, incrates/core/src/lib.rsit is,eprintln!never is; the same holds forcora scan --path projrun from the parent directory.