Skip to content

Fix Javadoc warning#860

Draft
tsh-hashimoto wants to merge 7 commits into
opensourcecobol:developfrom
tsh-hashimoto:doc/fix-javadoc-warning
Draft

Fix Javadoc warning#860
tsh-hashimoto wants to merge 7 commits into
opensourcecobol:developfrom
tsh-hashimoto:doc/fix-javadoc-warning

Conversation

@tsh-hashimoto

@tsh-hashimoto tsh-hashimoto commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

概要

./gradlew javadoc 実行時に出力されていた Javadoc の警告(22 件)を解消する。

いずれも libcobj/app/build.gradle.kts-Xdoclint:missing によって検出されるドキュメント不足の警告であり、内訳は次の通りである。

  • 明示的なコンストラクタを持たないクラスの、暗黙のデフォルトコンストラクタにコメントが無い(21 件)
  • int を返す C$SLEEP メソッドに @return が無い(1 件)

パッケージを横断して発生していた警告をすべて解消し、./gradlew javadoc が警告なしで完了する状態にした。あわせて、修正に伴って発生する静的解析(PMD)の指摘も解消している。

変更点

Javadoc 警告の解消

  • static ユーティリティ系クラス(17 件): コメント付きの private コンストラクタを追加し、インスタンス化を禁止した。対象は Const / CobolResolve / CobolSystemRoutine / CobolCallParams / CobolCheck / CobolConstant / CobolInspect / CobolIntrinsic / CobolString / CobolUtil / CobolFieldFactory / CobolFileFactory / CobolFileSort / CobolTerminal / CobolExceptionId / CobolExceptionInfo / CobolExceptionTabCode
  • データ / インスタンス系クラス(4 件): コメント付きの public デフォルトコンストラクタを明示した。対象は CobolFileKey / KeyComponent / Linage / CobolCallResult
  • C$SLEEP メソッド: 常に 0 を返す旨の @return タグを追加した。

静的解析(PMD)対応

上記の変更によって新たに検出された PMD 指摘を、以下の通り解消した。

  • static ユーティリティ系クラスは private コンストラクタのみを持つため、ClassWithOnlyPrivateConstructorsShouldBeFinal に従い final を付与した。
  • データ系クラスに明示したデフォルトコンストラクタは UnnecessaryConstructor に該当するため、Javadoc 用のコメントを維持したまま @SuppressWarnings("PMD.UnnecessaryConstructor") で抑制した。
  • CobolFileSortfinal 化したことで顕在化した protected フィールド(AvoidProtectedFieldInFinalClass)を、内部でのみ使用しているため private に変更した。
  • それに伴い未使用と判明した定数 COB_DESCENDINGUnusedPrivateField)を削除した。

その他

  • ローカルで spotlessCheck / pmdMain / spotbugsMain / javadoc を実行し、フォーマット・静的解析ともにパスすること、および Javadoc の警告が 0 件になることを確認済みである。
  • 本 PR には CI ワークフロー(.github/workflows/javadoc.yml)の変更は含まない。調査の過程で「Javadoc の警告が出ても CI が失敗しない」というワークフローの不具合(警告は標準エラー出力に出るが標準出力のみを検査していた)を発見したが、これを修正して警告検査を有効化すると、別要因である compileJava の警告(source/target value 8 is obsolete)が併せて検出され CI が失敗する。この解消には Java の source/target レベル引き上げというチームの合意が必要な変更を伴うため、ワークフローの修正は本 PR のスコープから除外している。

tsh-hashimoto and others added 7 commits July 21, 2026 01:58
The workflow ran `./gradlew javadoc` twice: the first run marked the
task up-to-date, so the second (tee'd to javadoc.log) was skipped and
produced no output. The warning grep then matched nothing and the job
always passed. Run javadoc only once, capturing its output to the log.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Javadoc writes its warnings (including the "N warnings" summary) to
stderr, but the pipeline only tee'd stdout to javadoc.log, so the
warning grep never matched and the job always passed. Redirect stderr
into the log with 2>&1.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
These classes expose only static members and are never instantiated.
Adding a documented private constructor silences the "use of default
constructor, which does not provide a comment" javadoc warning and
also prevents accidental instantiation.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
CobolCallResult, CobolFileKey, KeyComponent and Linage are instantiated
data classes with no explicit constructor. Declare an explicit,
documented public no-arg constructor to silence the "use of default
constructor, which does not provide a comment" javadoc warning while
keeping the existing behavior.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The C$SLEEP method returns an int status code but its javadoc had no
@return tag, triggering a "no @return" javadoc warning. Document that
it always returns 0.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Restore the workflow to its original form. Making the check actually
fail on warnings surfaces a pre-existing "source/target value 8 is
obsolete" compiler warning whose fix (bumping the Java source/target
level) needs team approval. Revert for now; the javadoc doclint
warnings themselves have been fixed separately.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The javadoc doclint fixes introduced PMD violations in static-analysis:

- Static utility classes now have only a private constructor, so PMD's
  ClassWithOnlyPrivateConstructorsShouldBeFinal fired. Mark them final.
- The documented no-arg constructors on the data classes (CobolFileKey,
  KeyComponent, Linage, CobolCallResult) trip UnnecessaryConstructor,
  which the repo enables while disabling UncommentedEmptyConstructor.
  Keep the documented constructors and suppress the rule locally.
- Making CobolFileSort final surfaced protected fields
  (AvoidProtectedFieldInFinalClass); they are only used internally, so
  reduce them to private. That in turn revealed COB_DESCENDING as an
  unused private field, so remove the dead constant.

Verified locally: spotlessCheck, pmdMain, spotbugsMain pass and javadoc
emits no doclint warnings.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@tsh-hashimoto tsh-hashimoto changed the title Doc/fix javadoc warning Fix Javadoc warning Jul 21, 2026
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