diff --git a/clippy.toml b/clippy.toml new file mode 100644 index 0000000..a260f2c --- /dev/null +++ b/clippy.toml @@ -0,0 +1,23 @@ +# SPDX-FileCopyrightText: 2026 Sephyi +# +# SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial + +# Minimal, pragmatic clippy config to catch common anti-patterns at lint time. +# +# Keep this file small. Each rule should have a clear justification in its +# `reason` so reviewers understand why the flagged call was blocked. + +# Disallow sync `std::process::Command` — the async pipeline must not block the +# tokio runtime. Use `tokio::process::Command` or wrap in +# `tokio::task::spawn_blocking` at async call-sites. Synchronous contexts +# (integration tests, CLI bootstrap before the runtime starts) may allow this +# lint locally with `#[allow(clippy::disallowed_methods)]` and a comment. +disallowed-methods = [ + { path = "std::process::Command::new", reason = "prefer tokio::process::Command or spawn_blocking in async contexts" }, +] + +# Disallow the `dbg!` macro — leftover debug scaffolding should never ship. +# Use `tracing::{debug,trace}` for durable diagnostics. +disallowed-macros = [ + { path = "std::dbg", reason = "leftover debug scaffolding; remove before committing" }, +] diff --git a/src/app.rs b/src/app.rs index cae18dc..537fc0b 100644 --- a/src/app.rs +++ b/src/app.rs @@ -990,6 +990,13 @@ impl App { // Verify we're in a git repo first let _git = GitService::discover()?; + // `hook_dir` runs under the Tokio runtime (`main` is `#[tokio::main]` + // and hook commands reach here via `app.run().await`), so this + // `std::process::Command` can block a worker thread. F-002 will + // migrate the hook / clipboard paths to `tokio::process::Command`; + // until then, allow the lint locally so the new clippy.toml rule + // does not block unrelated PRs. + #[allow(clippy::disallowed_methods)] let output = std::process::Command::new("git") .args(["rev-parse", "--git-dir"]) .output()?; diff --git a/tests/history.rs b/tests/history.rs index 53c7582..a49f7f7 100644 --- a/tests/history.rs +++ b/tests/history.rs @@ -2,6 +2,11 @@ // // SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial +// Keep `clippy::disallowed_methods` enabled for this file. If a synchronous +// helper needs `std::process::Command` to build git fixtures in a tempdir, +// allow it narrowly at that specific helper or call site with a short +// justification rather than silencing the lint for async tests as well. + use commitbee::services::history::{HistoryContext, HistoryService}; // ─── Subject Analysis (Pure Functions) ─────────────────────────────────────── diff --git a/tests/porcelain.rs b/tests/porcelain.rs index 0588174..121b997 100644 --- a/tests/porcelain.rs +++ b/tests/porcelain.rs @@ -23,6 +23,11 @@ //! deferred to a follow-up — it requires the full pipeline setup and belongs //! in its own test file. +// Integration tests are synchronous and legitimately use `std::process::Command` +// to shell out to `git` / the `commitbee` binary; the `disallowed_methods` rule +// in clippy.toml targets async-context misuse, which does not apply here. +#![allow(clippy::disallowed_methods)] + use std::collections::BTreeMap; use std::path::{Path, PathBuf}; use std::process::{Command, Stdio};