feat: Java / Kotlin / Ruby 対応を追加 (#12)#14
Open
k-buchi4696 wants to merge 2 commits into
Open
Conversation
既存の Go/Rust パターンを踏襲し、polyglot scorer/fixer を 3 言語追加: - score.py: _JAVA_FUNC_RE / _KOTLIN_FUNC_RE / _RUBY_FUNC_RE と各 _scan_* ヘルパ、_scan_block_comment_functions 汎用ヘルパ (Javadoc / KDoc は JSDoc の /** */ 検出を流用)、_is_jvm_test_file / _is_ruby_test_file を追加。_compute_ai_readiness に is_java / is_kotlin / is_ruby 分岐を追加 - fix.py: _fix_block_comment_file 汎用ヘルパと言語別ラッパーを追加。 _fix_function_docstrings にテストファイルスキップ付きで dispatch - init.py: test_file_patterns / test_setup_signals / dep_files / lint_tools / file_globs / test_commands を拡張 - tests/harness/test_java_kotlin_ruby_support.py: 新規 37 テスト (検出 / scorer / fixer / エンドツーエンド) 対応言語: Python, JS/TS, Go, Rust, Java, Kotlin, Ruby テスト 585 件パス (既存 548 + 新規 37)。ruff check クリーン。 注: コードレビューで CRITICAL/HIGH 指摘あり (Java regex のメソッド 本体誤検出、Ruby テストファイル判定が過剰、Ruby setter 名キャプチャ)。 同ブランチの後続コミットで対応予定。
コードレビューで挙がった全指摘への対応:
CRITICAL
- C1: Java regex がメソッド本体の return doFoo(x) / throw new X() /
if() / for() 等を誤ってメソッド宣言と判定していた問題を修正。
negative lookahead に制御フロー語 (return/throw/new/if/else/for/
while/do/switch/case/try/catch/finally/yield/assert/break/continue)
を追加し、パラメータリスト + 閉じ括弧 + 任意 throws 句 + { か ;
を要求するよう regex を厳格化
HIGH
- H1: _is_ruby_test_file / _is_jvm_test_file を repo 相対パスに限定。
Rails 系の lib/inspector/test/runner.rb のような本番コード配下の
"test"/"spec" セグメントが誤検出されていたのを修正。トップレベル
の spec/ / test/ と src/test/ のみを対象とする
- H2: Ruby setter def foo=(v) の `=` を捕捉するため _RUBY_FUNC_RE
の末尾を [?!=]? に変更
MEDIUM
- M2: Java return-type char class から ? を削除 (Kotlin nullable との
混同)
- M3: score.py / fix.py の java/kotlin/ruby 分岐を _BLOCK_LANG_DISPATCH
/ _BLOCK_FIX_DISPATCH の辞書に集約。次の言語追加は 1 行の登録で済む
LOW
- L1: 非 Javadoc ブロックコメント (/* plain */) を documented と
みなす既存挙動を pinning test として明文化
- L2: _is_jvm_test_file の冗長な境界ガードを削除
- L5/L6: Maven-only プロジェクト (pom.xml のみ) に ./gradlew test を
提案していた不具合を修正。dependency_file == "pom.xml" のとき
mvn test を出力
新規テスト 27 件 (計 612 件):
- C1 回帰 (method body false-positive)
- Java edge case: abstract / interface / throws / annotation 別行
- Kotlin edge case: fun interface / annotation
- Ruby setter (def foo=)
- _is_jvm_test_file / _is_ruby_test_file 直接テスト
- src/test/ 除外統合テスト (Java / Kotlin)
- 冪等性テスト (2 回目の fixer は no-op)
- 混在ファイル (一部ドキュメント済み → 未ドキュメントのみ追加)
- Maven/Gradle test_command 切り替え
ruff check クリーン。
Collaborator
Author
|
CI 失敗は #15 起因で本 PR のスコープとは無関係です。
#15 (CI 修正) をマージ後、本 PR の CI を再実行すれば通るはずです。 |
3 tasks
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
#12 対応。既存の Go/Rust パターンを踏襲し polyglot scorer/fixer を 3 言語拡張。
.java/.kt/.rbの関数定義を検出し、Javadoc / KDoc / YARD カバレッジを AI-Readiness に反映pom.xml/build.gradle.kts/Gemfileを依存ファイルとして認識、Maven/Gradle を区別した test コマンドを提案実装の要点
_scan_block_comment_functions汎用ヘルパを新設し Javadoc/KDoc は JSDoc 検出 (/** */) を流用_scan_line_comment_functions(#line prefix) を流用_BLOCK_LANG_DISPATCH/_BLOCK_FIX_DISPATCHの辞書駆動に統合コードレビュー対応 (2 コミット目)
初回コミット後のレビューで挙がった CRITICAL/HIGH/MEDIUM/LOW 全件を同ブランチ内で対応済み:
return doFoo(x)/throw new X()を誤検出していた問題を修正 (負の先読みに制御フロー語を追加、パラメータリスト+{/;を要求する構造に厳格化)_is_ruby_test_file/_is_jvm_test_fileを repo 相対パスに限定。lib/inspector/test/runner.rbのような本番コードの誤除外を修正def foo=(v)の=捕捉f59aeeb参照Test plan
ruff check .クリーン既知の制約
/* plain block comment */を Javadoc と区別しない (既存 JS scanner と挙動統一、pinning test で明文化)Closes #12