Java: `StringLiteral` matches String concatenation of two String literals
Aperta
documentation
Java
question
- Lingua principale
- CodeQL
- Stelle
- 10.1k
- Fork
- 2.1k
- Merge medio
- 2g 15h
- PR unite (30g)
- 141
Descrizione
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/)
Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.