github / github/codeql

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

未關閉
#7,309 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
Java question
主要語言
CodeQL
星號
10.1k
分支
2.1k
平均合併
2 天 15 小時
30 天內合併 PR
141

描述

### 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/)

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。