Skip to content

F-028: refactor: extract binary to lib.rs and enforce #![forbid(unsafe_code)]#28

Open
Sephyi wants to merge 1 commit intodevelopmentfrom
audit/f-028-forbid-unsafe-main-refactor
Open

F-028: refactor: extract binary to lib.rs and enforce #![forbid(unsafe_code)]#28
Sephyi wants to merge 1 commit intodevelopmentfrom
audit/f-028-forbid-unsafe-main-refactor

Conversation

@Sephyi
Copy link
Copy Markdown
Owner

@Sephyi Sephyi commented Apr 22, 2026

Summary

refactor: extract binary to lib.rs and enforce #![forbid(unsafe_code)].

Audit context

Closes audit entry F-028 from #3.

Verification

  • cargo fmt --check
  • cargo clippy --all-targets --all-features -- -D warnings
  • cargo test --all-targets

Note: one pre-existing test porcelain_exits_within_timeout_with_no_staged_changes is a known macOS cold-start flake that reproduces on unmodified development — unrelated to this change.

The `src/main.rs` binary re-declared `mod app; mod cli; mod config; …`,
which built a second module tree alongside `src/lib.rs`. That second tree
did not inherit the `#![forbid(unsafe_code)]` attribute from `lib.rs`,
leaving the binary half of the crate silently unprotected.

Shrink `main.rs` to a thin entry point that imports from the library
crate (`use commitbee::{App, Cli, error};`) and add
`#![forbid(unsafe_code)]` at its top so both compilation units enforce
the lint. `lib.rs` already declared every module publicly, so no other
file needed updating.

Closes audit entry F-028 from #3.
Copilot AI review requested due to automatic review settings April 22, 2026 19:51
@Sephyi Sephyi added the audit Codebase audit cleanup (issue #3) label Apr 22, 2026
@Sephyi Sephyi self-assigned this Apr 22, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors the CLI binary crate to rely on the library crate (lib.rs) for module structure, and closes the audit gap where #![forbid(unsafe_code)] was enforced in the library but not in the binary crate.

Changes:

  • Add #![forbid(unsafe_code)] to src/main.rs.
  • Remove binary-local mod ... declarations and import App, Cli, and error from the commitbee library crate.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

audit Codebase audit cleanup (issue #3)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants