Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

InlineTrivialConstant misses an empty-string constant with a parenthesized initializer

オープン 初心者向け
#6,217 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@Youssef-Khogaly がすでに取り組んでいます。

2026年10月21日 から。

  • #6222 @Youssef-Khogaly による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
java
領域
testing-qa

調査の方向性

InlineTrivialConstant matcherから始め、初期化式のマッチングがParenthesizedTreeを処理するか確認してください。issueでは手掛かりとしてASTHelpers.stripParenthesesが挙げられています。報告された例と見逃された空文字列の例を、このチェックの既存のテストと比較してください。両方の初期化式で検出結果が出て、このチェックのテストが通れば完了です。

索引モデルが issue の本文から書いたものです。

説明

Error Prone version

Error Prone 2.49.0 (javac 21.0.8, --source/--target 21)

Affected checks

InlineTrivialConstant

Description

Adding redundant parentheses around an empty-string initializer causes InlineTrivialConstant to miss a trivial constant. The check reports private static final String EMPTY = "";, but does not report private static final String EMPTY = ("");.

Per JLS §15.8.5, parentheses around an expression do not change its value, type, or constant-expression status. The parenthesized empty string is still the same trivial constant.

I verified the following pair on Error Prone 2.49.0:

Check Rewrite BEFORE AFTER Effect
InlineTrivialConstant "" → ("") 1 0 false negative

The matcher appears to inspect the initializer without looking through ParenthesizedTree. A possible fix is to unwrap the initializer before matching it, for example with ASTHelpers.stripParentheses.

Reproducers
InlineTrivialConstant — ("") is missed
// BEFORE — 1 finding
public class Sample {
  private static final String EMPTY = "";
}
// AFTER — 0 findings
public class Sample {
  private static final String EMPTY = ("");
}
Expected behavior

Both versions should produce 1 InlineTrivialConstant finding. Adding redundant parentheses around the empty-string initializer does not change its value or constant-expression status.

Actual behavior

The BEFORE version produces 1 finding. The AFTER version produces 0 findings after the empty-string initializer is parenthesized.

主要言語
Java
スター
7.3k
フォーク
827
平均マージ
21時間 35分
マージ済み PR(30日)
60

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

google/error-prone のほかの issue

google/error-prone の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。