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:
Running PMD through: Other
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4