Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[java] UseEqualsToCompareStrings should consider return type #3843

Closed
ghost opened this issue Mar 15, 2022 · 1 comment
Closed

[java] UseEqualsToCompareStrings should consider return type #3843

ghost opened this issue Mar 15, 2022 · 1 comment
Labels
a:false-negative PMD doesn't flag a problematic piece of code in:type-resolution Affects the type resolution code
Milestone

Comments

@ghost
Copy link

ghost commented Mar 15, 2022

Affects PMD Version:6.42.0

Rule:UseEqualsToCompareStrings

Please provide the rule name and a link to the rule documentation:
https://pmd.github.io/latest/pmd_rules_java_errorprone.html#useequalstocomparestrings

Description:
Hi, I found a false negative about the rule UseEqualsToCompareStrings. Please review the following code example. PMD should have reported a warning at line 5 because the string x is compared with another string, but it doesn't. Hence, I think it is a false negative.

Code Sample demonstrating the issue:

String getLiteral() {
  return "hello";
}
void UseEqualsToCompareStrings(String x) {
  if (x == getLiteral()) {} // a false negative should report
}

Expected outcome:

PMD should report a violation at line 5, but doesn't. This is a false-negative.

Running PMD through: [Maven]

@ghost ghost added the a:false-negative PMD doesn't flag a problematic piece of code label Mar 15, 2022
@oowekyala oowekyala added in:type-resolution Affects the type resolution code needs-backport labels Mar 15, 2022
@jsotuyod
Copy link
Member

This is fixed in PMD 7.0.0-rc1. It won't be backported to PMD 6.

@oowekyala oowekyala added this to the 7.0.0 milestone Apr 24, 2023
@adangel adangel changed the title UseEqualsToCompareStrings should consider return type [java] UseEqualsToCompareStrings should consider return type Apr 25, 2023
adangel added a commit that referenced this issue Apr 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:false-negative PMD doesn't flag a problematic piece of code in:type-resolution Affects the type resolution code
Projects
None yet
Development

No branches or pull requests

2 participants