Repository navigation
build(lint): deny tests outside test modules - #21
Conversation
Enable clippy::tests_outside_test_module as a warning so CI (-D warnings) rejects #[test] functions outside a #[cfg(test)] module. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Review summary1 blocking finding (P1)
The lint itself and the documented I couldn't run cargo in the review sandbox, so this conclusion comes from reading the CI and hook commands and from how rustc's 🤖 Generated with Claude Code |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1c0b5b75aa
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
#[test] functions are compiled out of non-test builds, so tests_outside_test_module never fired under plain `cargo clippy`. Pass --all-targets in CI and in the pre-commit hook. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
@codex review |
Review summaryI found no blocking issues.
I didn't run clippy myself: running commands needed approval in this environment. No inline findings. |
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
概要
Cargo.tomlの[lints.clippy]にtests_outside_test_module = "warn"を追加した.CI は clippy を-D warningsで実行するので,#[cfg(test)]モジュール外の#[test]関数は CI で失敗する.置き換える ast-grep 規則
agent-config で安定して動かせなかった,
#[test]関数がテストモジュール外にあることを検出するブロッキング規則を,この clippy lint で置き換える.既知の誤検知と対処
ピン留めされた clippy 0.1.95 では,
#[cfg(all(unix, test))] mod tests { #[test] fn t() {} }のような複合 cfg のテストモジュール内のテストも報告される(通常の#[cfg(test)] mod testsは報告されない).このような複合 cfg のテストモジュールは稀なので,lint を外さず,レビューされた抑制コメントで例外を扱う方針とする.該当するモジュールには,理由付きで次のように書く.テンプレートはallow_attributes_without_reasonにより理由を必須にしている.#[expect(clippy::tests_outside_test_module, reason = "compound cfg test module is a known false positive")]検証
使い捨ての
src/bin/throwaway.rsでcargo clippy --all-targetsを実行した(確認後に削除済み).#[cfg(test)]外の#[test]: 警告される.#[cfg(all(unix, test))] mod tests: 警告される(上記の既知の誤検知).#[cfg(test)] mod tests(src/main.rs): 警告されない.テンプレートの検査コマンド
cargo fmt --check,cargo clippy --all-targets -- -D warnings,cargo testはすべて成功した.計画からの重要な変更: 複合 cfg が報告されない前提は成り立たなかったため,上記の抑制方針を明記した.
🤖 Generated with Claude Code