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] UnusedLocalVariable: false-negative with array #2130

Closed
linusjf opened this issue Nov 25, 2019 · 1 comment · Fixed by #3113
Closed

[java] UnusedLocalVariable: false-negative with array #2130

linusjf opened this issue Nov 25, 2019 · 1 comment · Fixed by #3113
Labels
a:false-negative PMD doesn't flag a problematic piece of code
Projects
Milestone

Comments

@linusjf
Copy link

linusjf commented Nov 25, 2019

Affects PMD Version:
6.19.0

Rule:
UnusedLocalVariable

Description:
An unused array object is not flagged as unused but flagged as DU-anomaly by rule DataflowAnomalyAnalysis. Both should happen. Comment in code states that this is a TODO.

https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/UnusedLocalVariableRule.java
Code Sample demonstrating the issue:

package pmdtests;

import java.lang.reflect.Constructor;

public final class Construct {

  private Construct() {
    throw new IllegalStateException("Private constructor.");
  }

  public static void main(String... args) {
    // get all visible constructors
    Constructor<?>[] constructors = String.class.getConstructors();
  }
}

Running PMD through: [CLI | Ant | Maven | Gradle | Designer | Other]

@adangel adangel changed the title [java] Unused variable not flagged if type is array. [java] UnusedLocalVariable: false-negative with array Nov 25, 2019
@adangel adangel added the a:false-negative PMD doesn't flag a problematic piece of code label Nov 25, 2019
@oowekyala oowekyala added this to the 7.0.0 milestone Nov 10, 2020
oowekyala added a commit to oowekyala/pmd that referenced this issue Nov 10, 2020
@oowekyala oowekyala linked a pull request Feb 19, 2021 that will close this issue
4 tasks
@oowekyala oowekyala added this to Done in PMD 7 Apr 3, 2021
@adangel adangel mentioned this issue Jan 23, 2023
55 tasks
@adangel
Copy link
Member

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-negative PMD doesn't flag a problematic piece of code
Projects
No open projects
PMD 7
  
Done
Development

Successfully merging a pull request may close this issue.

3 participants