feat(lint): rule-test coverage check + global testing.md codify (Bundle 137+138)#165
Merged
Conversation
…odify (Bundle 137+138, TOML meta field 方式)
- src/hooks-post-tool-linter/src/main.rs:
- CustomRule に test_coverage: Option<CustomRuleTestCoverage> field 追加
- rule_test_coverage_check cargo test 新規 (helper 4 関数に分割)
- load_deployed_custom_rules / extract_existing_test_fn_names
- classify_rule_extensions / check_main_ext_coverage / check_other_ext_coverage / check_main_ext_keys_sanity
- collect_rule_coverage_gaps
- test gap 補填 (合計 +7 tests, 121 → 128):
- rule② (no-personal-paths): positive×2 + negative×1 (元 0 tests, 配布後初の検証)
- rule⑥ (no-ephemeral-todo-reference) yaml: positive×1 + negative×1
- rule⑥ (no-ephemeral-todo-reference) yml: positive×1
- .claude/custom-lint-rules.toml:
- 全 10 rule に [rules.test_coverage] meta field を宣言
- 主要拡張子 (rs/toml/yaml/yml) を targets する rule は main_ext_tests.<ext> で各 ext に 1+ test を明示
- 非主要専用 rule は other_ext_tests でカバレッジ宣言
- ~/.claude/rules/common/testing.md (グローバル):
- 新 section 'Custom Lint Rule Test Coverage' を追加
- 命名規約 vs TOML meta field の trade-off と採用根拠 (案 b) を codify
- 派生プロジェクト (techbook-ledger / auto-review-fix-vc) へ自動波及
順位 137 + 138 (PR #163 post-merge-feedback T1-#1 + T3-#1 採用)。命名規約に依存しない明示的 mapping を採用したのは AI 生成の揺らぎを構造的に抑止する意図 (ユーザー指示)。
- docs/todo-summary.md: 行 137 + 138 を削除 (table) - docs/todo8.md: 順位 137/138 entry block を削除 (合計 90 行 -) PR 本作業 (@-: feat(lint) commit) で実装 + ドキュメント codify が land したため、todo entries を片付け。
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
💤 Files with no reviewable changes (2)
📝 WalkthroughWalkthroughこのプルリクエストでは、カスタムリント規則に対するテストカバレッジメタデータシステムを導入します。TOML 設定ファイルに各規則が満たすべきテスト関数名を宣言し、Rust 実装側でそれらが実装に存在すること、かつ拡張子ごとの要件を満たすことを自動検証します。 Changesテストカバレッジメタデータシステムの導入
🎯 4 (Complex) | ⏱️ ~45 minutesPossibly Related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Summary
Bundle 137 + 138 を実装。
.claude/custom-lint-rules.tomlの各 rule に対する test カバレッジを TOML meta field + cargo test で機械強制する 2 層構成を導入。命名規約に依存しない明示的 mapping を採用 (案 b) し、AI 生成の test 命名揺らぎを構造的に抑止する。由来: PR #163 post-merge-feedback T1-#1 + T3-#1 採用 (Frequency High = PR #110/#151/#152/#155 の 4 PR 累積観測)。
変更内容
順位 137: Rule-Test Coverage Check Cargo test (Tier 1, M)
CustomRuleにtest_coverage: Option<CustomRuleTestCoverage>field 追加 (src/hooks-post-tool-linter/src/main.rs)rule_test_coverage_checkcargo test 新規実装 (50 行制限のため 4 helper 関数に分割)load_deployed_custom_rules— deploy 済 TOML 読込 + false-green guardextract_existing_test_fn_names— main.rs から fn 名を regex 抽出 + 自己存在 guardclassify_rule_extensions— 主要 (rs/toml/yaml/yml) vs 非主要に分類check_main_ext_coverage/check_other_ext_coverage/check_main_ext_keys_sanity— 検証ロジック[rules.test_coverage]meta field 宣言 (.claude/custom-lint-rules.toml)Test gap 補填 (+7 tests, 121 → 128)
no-personal-paths(元 0 tests — 配布後初の検証):no_personal_paths_detects_windows_user_path_in_mdno_personal_paths_detects_unix_home_path_in_txtno_personal_paths_skips_placeholder_pathsno-ephemeral-todo-referenceyaml/yml (主要拡張子 gap):no_ephemeral_todo_detects_yaml_ephemeral_referenceno_ephemeral_todo_yaml_skips_permanent_adr_referenceno_ephemeral_todo_detects_yml_ephemeral_reference順位 138: Global testing.md codify (Tier 3, XS)
~/.claude/rules/common/testing.mdに新 section "Custom Lint Rule Test Coverage" 追加 (グローバル設定、派生プロジェクト = techbook-ledger / auto-review-fix-vc へ自動波及)順位 137 + 138 entry 削除
設計判断
案 a (命名規約方式) vs 案 b (TOML meta field 方式) — 案 b 採用
ユーザー指示「コーディングエージェントによる揺らぎの余地を減らす意図」に従い、明示的 mapping を採用。
ps_empty_catch_*/md_mutable_anchor_*等の混在で adapt 困難必須カバレッジ scope
主要拡張子 (
rs/toml/yaml/yml) × 全 rule に 1+ test を必須化。非主要拡張子は rule あたり 1+ positive test で代替 (test 関数爆発を抑制)。Verification
Negative-case sanity check (load-bearing 証明)
no_write_result_discard_TYPO_NONEXISTENTを rule⑩ の meta field に注入 →rule_test_coverage_checkが以下メッセージで fail:restore 後は green に戻ることを確認済。
全体テスト + ビルド
cargo test -p hooks-post-tool-linter: 128 passed; 0 failedcargo build --workspace: clean (dead_code warning は#[allow(dead_code)]で抑制、test 専用 field のため)pnpm build:all: 全 7 exe ビルド +.claude/への配布完了Backward Compatibility
#[serde(default)]+Option<CustomRuleTestCoverage>により、派生プロジェクト (techbook-ledger / auto-review-fix-vc) で 古い TOML (meta field 不在) を持つ deploy 先でも production hook は壊れない。cargo test実行時のみ "meta field 不在" として fail する設計で、production と test の責務を分離。Commit 構成 (2 commits)
feat(lint): rule-test coverage check cargo test + global testing.md codify(c5b5ad7) — 実装 + ドキュメント codify (TOML + main.rs)docs(todo): 順位 137 + 138 完了に伴い削除(4f7e021) — todo entries cleanupmemory rule
git-workflow.md § jj 環境完了タスク削除手順に従い、本作業と todo 削除を別 commit に分離。Test plan
cargo test -p hooks-post-tool-linterで 128 tests greencargo build --workspaceで warning なしpnpm build:allで全 exe ビルド成功🤖 Generated with Claude Code
Summary by CodeRabbit
リリースノート
Tests
Chores