github / github/codeql

Java: `StringLiteral` matches String concatenation of two String literals

オープン
#5,469 コメント 5 件 リアクション 0 件 担当者 0 名 GitHub で見る
documentation Java question
主要言語
CodeQL
スター
10.1k
フォーク
2.1k
平均マージ
2日 15時間
マージ済み PR(30日)
141

説明

It appears the class `StringLiteral` matches String concatenation of two String literals.
This is not how the JLS [defines a String literal](https://docs.oracle.com/javase/specs/jls/se16/html/jls-3.html#jls-3.10.5). Instead they should be matched as separate String literals being operands of an `AddExpr` (which is a `CompileTimeConstantExpr`).

Query finding these erroneous `StringLiteral`s:
```ql
import java

from StringLiteral s
where
exists(s.getLiteral().indexOf("+"))
and not exists(s.getValue().indexOf("+"))
select s
```
[Query Console link](https://lgtm.com/query/1720584166166636188/)

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

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

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