Affects PMD Version: 6.30.0
Rule: UseEqualsToCompareStrings
Description:
The rule detects a violation even though not two String variables but the results of the ".isEmpty()" method calls are compared.
This might be related to #2976 as CompareObjectsWithEquals falsely detects this as well.
Neither of the violations are reported if the variables are declared as "String" instead of "var".
Code Sample demonstrating the issue:
final Matcher matcher = ...;
if (matcher.matches()) {
final var firstString = matcher.group("a");
final var secondString = matcher.group("b");
if (firstString.isEmpty() != secondString.isEmpty()) { // <- violation
// ...
}
}
Expected outcome:
- The compared values are boolean, not Strings -> false-positive
Running PMD through: Other
Affects PMD Version: 6.30.0
Rule: UseEqualsToCompareStrings
Description:
The rule detects a violation even though not two String variables but the results of the ".isEmpty()" method calls are compared.
This might be related to #2976 as CompareObjectsWithEquals falsely detects this as well.
Neither of the violations are reported if the variables are declared as "String" instead of "var".
Code Sample demonstrating the issue:
Expected outcome:
Running PMD through: Other