False positive report of `UnusedVariable` for fields used with JUnit5 `FieldSource` annotation
Open
- Dominant language
- Java
- Stars
- 7.2k
- Forks
- 820
- Avg merge
- 5h 9m
- Merged PRs (30d)
- 50
Description
A variable that is used by JUnit5's `FieldSource` annotation will be flagged as an unused variable. The `FieldSource` annotation was introduced in JUnit version 5.11.
Example:
```java
class FieldSourceTest {
private static final List fooParameters = List.of("apple", "banana");
@ParameterizedTest
@FieldSource("fooParameters")
public void foo(String bar) {
System.out.println(bar);
}
}
```
Output:
```
FieldSourceTest.java:2: error: [UnusedVariable] The field 'fooParameters' is never read.
```
This is similar to https://github.com/google/error-prone/issues/2335, where methods used by `MethodSource` were flagged as unused.
Contributor guide
Assessment
This issue has not been assessed yet.