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] PrematureDeclaration false positive for unused variables #3221

Closed
adangel opened this issue Apr 16, 2021 · 1 comment · Fixed by #3199
Closed

[java] PrematureDeclaration false positive for unused variables #3221

adangel opened this issue Apr 16, 2021 · 1 comment · Fixed by #3199
Labels
a:false-positive PMD flags a piece of code that is not problematic
Milestone

Comments

@adangel
Copy link
Member

adangel commented Apr 16, 2021

Affects PMD Version: 6.33.0

Rule: PrematureDeclaration

Description:

Don't report variables that are not used at all. Those should be left to UnusedLocalVariable.

Code Sample demonstrating the issue:

public String wrongEscapeSequences() 
    {
        final String r1 = "\u0008"; // unused var - not a premature declaration
        return "\u000csssdfsd";
    }

(from https://github.com/checkstyle/checkstyle/blob/checkstyle-8.10/src/it/resources/com/google/checkstyle/test/chapter2filebasic/rule232specialescape/InputIllegalTokenText.java#L17)

Expected outcome:

  • Does PMD report a violation, where there shouldn't be one? -> false-positive
@adangel adangel added the a:false-positive PMD flags a piece of code that is not problematic label Apr 16, 2021
@adangel adangel added this to the 7.0.0 milestone Apr 16, 2021
@adangel adangel linked a pull request Apr 16, 2021 that will close this issue
4 tasks
@adangel adangel mentioned this issue Jan 23, 2023
55 tasks
@adangel
Copy link
Member Author

adangel commented Apr 22, 2023

This has been fixed with PMD 7.0.0-rc1.

@adangel adangel closed this as completed Apr 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:false-positive PMD flags a piece of code that is not problematic
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant