CodeQL: Support multiple types for `instanceof`
- 主要言語
- CodeQL
- スター
- 10.1k
- フォーク
- 2.1k
- 平均マージ
- 2日 15時間
- マージ済み PR(30日)
- 141
説明
Currently `instanceof` only supports a single type as right operand. This can make its usage quite verbose when multiple alternative type checks have to be performed. For example search in the CodeQL source with the following Regex (increasing or decreasing the number in `{3,}` to find longer or shorter chains):
```
(.+) instanceof [a-zA-Z]+([\s\n]+or[\s\n]+\1 instanceof [a-zA-Z]+){3,}
```
This finds for example:
- https://github.com/github/codeql/blob/3119885a9b21951aafac88e01c946b3e7cfbe163/java/ql/lib/semmle/code/java/ControlFlowGraph.qll#L441-L451
- https://github.com/github/codeql/blob/3119885a9b21951aafac88e01c946b3e7cfbe163/java/ql/lib/semmle/code/java/JDK.qll#L157-L161
Would it be possible to allow multiple types for the `instanceof` expression? The syntax could be similar to a set literal, also allowing a trailing comma (except that currently a set literal is defined as expression, so it would not be valid for types), for example:
```codeql
this instanceof [PrimitiveType, NullType, VoidType, BoxedType, TypeString]
```
コントリビューションガイド
評価
この issue はまだ評価されていません。