github / github/codeql

Java: Same type specified multiple times in `throws` clause is modeled as single CodeQL `Exception` with multiple locations

Aperta
#7,309 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
Java question
Lingua principale
CodeQL
Stelle
10.1k
Fork
2.1k
Merge medio
2g 15h
PR unite (30g)
141

Descrizione

### Description
When a callable declares the same exception type multiple times in a `throws` clause, it is represented by CodeQL as a single `Exception` with multiple `getLocation()` results. This is rather counterintuitive and confusing.
Expected would be that each exception type specified in the `throws` clause has its own `Exception` element with a single location, even if the same exception type occurs multiple times.

### Example
Java code:
```java
public void doSomething() throws IllegalArgumentException, IllegalArgumentException {
}
```

CodeQL query:
```ql
import java

from Exception e
where
e.fromSource()
and count(e.getLocation()) > 1
select e, e.getLocation()

```
[Query Console link](https://lgtm.com/query/4998057520081507908/)

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.