github / github/codeql

False positive, java/unused-reference-type and JUnit 5 classes

Đang mở
#11,989 2 bình luận 1 reaction 0 người được giao Xem trên GitHub
false-positive
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ả

JUnit Tests using JUnit 5 are reported as java/unused-reference-type. This is because the JUnit 5 convention is to use package scoped class and method names. This rule should be checking for methods with JUnit annotations (e.g. `@Test`, `@BeforeEach`, `@ParameterizedTest`). The [current check](https://github.com/github/codeql/blob/3059ce307009d40afb690aa712c96e422cf76753/java/ql/src/Violations%20of%20Best%20Practice/Dead%20Code/DeadRefTypes.ql#L44:L45) only looks for subsclassing of TestCase, which hasn't been applicable since JUnit 4.

**Code samples or links to source code**

Example test code that would be reported as unused.
```
class MyTest
{
@Test
void test()
{
// some test code.
}
}
```
Example false positive.
https://github.com/real-logic/aeron/security/code-scanning/1583

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.