So many false positives that I doubt it actually works
- Ngôn ngữ chính
- CodeQL
- Star
- 10.1k
- Fork
- 2.1k
- Merge trung bình
- 2 ngày 15 giờ
- Pull request đã merge (30 ngày)
- 141
Mô tả
**Description of the false positive**
I am constantly getting the following in my Java project.
```
Useless parameter
The parameter '' is never used.
```
```
Unread local variable
Variable '' is never read.
```
This is so frequente that I am at a point that I am seriously doubting the capacity of this tool of really working for whatever it proposes itself to do.
All parameters and variables it points as being useless or unread are always read, sometimes in the literal next line.
**Code samples or links to source code**
https://github.com/Scoppio/mekhq/blob/79a0f780ba5b70b46deea320962b9f6a4d8bdb19/MekHQ/src/mekhq/campaign/autoresolve/acar/handler/StandardUnitAttackHandler.java#L173
```Java
private int[] calculateDamage(
Formation attacker, // CodeQL - Useless parameter
StandardUnitAttack attack, // CodeQL - Useless parameter
SBFUnit attackingUnit, Formation target) {
int bonusDamage = 0; // CodeQL - Unread local variable
if (attack.getManeuverResult().equals(StandardUnitAttack.ManeuverResult.SUCCESS)) {
bonusDamage += 1;
}
var damage = attackingUnit.getElements().stream().mapToInt(e -> e.getStandardDamage().getDamage(attack.getRange()).damage).toArray();
return processDamageByEngagementControl(attacker, target, bonusDamage, damage);
}
```
As you can see, attacker parameter is used as parameter for processDamageByEngagementControl (it uses attacker inside), attack parameter is used when accessing `attack.getRange()`, and the variable bonusDamage is also used being passed as a parameter to processDamageByEngagementControl which then consumes it.
This is just a sample of my common experience with CodeQL, I often from 12 to 20 false positives sauing a parameter is useless or a variable is never read in all my pull requests.
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu với mẫu Java được liên kết và phương thức calculateDamage, sau đó tái hiện các chẩn đoán được báo cáo cho tham số và biến cục bộ. Truy vết truy vấn CodeQL phát ra chúng và bổ sung phạm vi kiểm thử hồi quy để những cách sử dụng hợp lệ như thế này không còn được báo cáo.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- java
- Lĩnh vực
- security, tooling
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 25/100