A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pmd/pmd/issues/2979 below:

FP with "var" variables · Issue #2979 · pmd/pmd · GitHub

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