Skip to content

feat: ParsedNames 構造体によるコンパイルタイムガード#68

Merged
makinzm merged 3 commits intomainfrom
feat/pr68-parsed-names-guard
Mar 23, 2026
Merged

feat: ParsedNames 構造体によるコンパイルタイムガード#68
makinzm merged 3 commits intomainfrom
feat/pr68-parsed-names-guard

Conversation

@makinzm
Copy link
Copy Markdown
Owner

@makinzm makinzm commented Mar 23, 2026

Summary

  • Parser::parse_names の戻り値を Vec<RawName> から ParsedNames 構造体に変更
  • ParsedNames に新フィールドを追加すると、Default 未実装のため全パーサーでコンパイルエラーが発生し対応漏れを防止
  • PHP / Python に NameKind::Variable 抽出を追加(これまで未対応だった)
  • README のフィーチャーマトリックスで PHP の naming convention に ✅ を追加

背景

従来の Vec<RawName> 戻り値では、新しい NameKind を追加しても既存パーサーがそれを無視(空 Vec を返す)してもコンパイルが通ってしまい、対応漏れが検出できなかった。

ParsedNames 構造体(Default 非実装)を使うことで、Rust の構造体フィールド網羅性チェックにより、新フィールド追加時に全パーサーでコンパイルエラーが発生するようになった。

変更箇所

  • domain/entity/name.rs: ParsedNames 構造体 + into_all() メソッド追加
  • domain/repository/parser.rs: Parser トレイトの戻り値変更
  • infrastructure/parser/mod.rs: partition_names() ヘルパー追加、DispatchingParser 対応
  • infrastructure/parser/*.rs: 全7言語パーサーを ParsedNames 対応に修正
  • infrastructure/parser/php.rs: property_declaration / const_declaration の Variable 抽出追加
  • infrastructure/parser/python.rs: assignment の Variable 抽出追加
  • usecase/check_architecture.rs: into_all() で flatten、NoOpParser mock 更新

Test plan

  • cargo check でコンパイルエラー0件
  • cargo test で全351テスト通過
  • lefthook(clippy + fmt + test)全通過
  • TDD: RED(コンパイルエラー17件確認 → --no-verify コミット)→ GREEN(全修正 → lefthook 通過)

🤖 Generated with Claude Code

makinzm and others added 3 commits March 23, 2026 22:37
…時に全パーサーでコンパイルエラーを発生させるガードが必要

- ParsedNames 構造体を domain/entity/name.rs に追加(Default 非実装)
- Parser::parse_names の戻り値を Vec<RawName> → ParsedNames に変更
- 全7言語パーサー + Dispatcher + usecase で17個のコンパイルエラーを確認

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ind 追加時に全パーサーでコンパイルエラーを発生させるガードが必要

- ParsedNames 構造体(Default 非実装)により構造体フィールド網羅性でガード
- partition_names ヘルパーで Vec<RawName> → ParsedNames への変換を共通化
- PHP / Python に Variable 抽出を追加(property_declaration, const_declaration / assignment)
- usecase 側で into_all() により Vec<RawName> に flatten
- 全テスト通過確認

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@makinzm makinzm merged commit 079d5ff into main Mar 23, 2026
9 checks passed
@makinzm makinzm deleted the feat/pr68-parsed-names-guard branch March 23, 2026 13:53
@makinzm makinzm mentioned this pull request Mar 23, 2026
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant