You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description:
Under certain circumstances (could not find a clear pattern yet, might be caused by the varargs parameter being a field in a different class), the ConfusingArgumentToVarargsMethod rule triggers even though it should not. This can happen for different varargs methods, when called with a single parameter of the same type, such as: MessageFormat,format(PATTERN, ARG) List.of(SomeEnum.CONSTANT)
Code Sample demonstrating the issue:
Two classes, in separate files
Messages.java:
Expected outcome:
PMD reports a violation at line PmdExample.java:3, but that's wrong. That's a false positive.
Running PMD through:CLI
I was unable to reproduce this example with gradle.
In a more complex codebase, this also happens with gradle, but I could not get that working with a simple example.
The text was updated successfully, but these errors were encountered:
oowekyala
changed the title
[java] Incorrect identification of varargs calls
[java] ConfusingArgumentToVarargsMethod FP when types are unresolved
Nov 28, 2024
Affects PMD Version:
7.2.0
Rule:
ConfusingArgumentToVarargsMethod
https://docs.pmd-code.org/latest/pmd_rules_java_errorprone.html#confusingargumenttovarargsmethod
Description:
Under certain circumstances (could not find a clear pattern yet, might be caused by the varargs parameter being a field in a different class), the ConfusingArgumentToVarargsMethod rule triggers even though it should not. This can happen for different varargs methods, when called with a single parameter of the same type, such as:
MessageFormat,format(PATTERN, ARG)
List.of(SomeEnum.CONSTANT)
Code Sample demonstrating the issue:
Two classes, in separate files
Messages.java:
PmdExample.java
Expected outcome:
PMD reports a violation at line PmdExample.java:3, but that's wrong. That's a false positive.
Running PMD through: CLI
I was unable to reproduce this example with gradle.
In a more complex codebase, this also happens with gradle, but I could not get that working with a simple example.
The text was updated successfully, but these errors were encountered: