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] UselessOperationOnImmutable various false negatives with String #4513

Closed
adangel opened this issue Apr 27, 2023 · 0 comments · Fixed by #4501
Closed

[java] UselessOperationOnImmutable various false negatives with String #4513

adangel opened this issue Apr 27, 2023 · 0 comments · Fixed by #4501
Labels
a:false-negative PMD doesn't flag a problematic piece of code
Milestone

Comments

@adangel
Copy link
Member

adangel commented Apr 27, 2023

Affects PMD Version: 6.x

Rule: UselessOperationOnImmutable

Description:

This is already fixed with PMD 7.0.0-rc1.
Found via #3123

Code Sample demonstrating the issue:

public class TestCase {
  public void method1(String s) {
    s.trim();
  }
  public void method2() {
   String.valueOf(0);
  }
  public void method3() {
   String.valueOf(0).trim();
  }
}

Expected outcome:

PMD should report a violation at lines 3,6,9 but doesn't. This is a false-negative.

@adangel adangel added the a:false-negative PMD doesn't flag a problematic piece of code label Apr 27, 2023
@adangel adangel added this to the 7.0.0 milestone Apr 27, 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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant