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] ConstructorCallsOverridableMethod should consider method calls with var access #4099

Closed
vanguard-1024 opened this issue Aug 23, 2022 · 0 comments · Fixed by #4101
Closed
Assignees
Labels
a:false-negative PMD doesn't flag a problematic piece of code
Milestone

Comments

@vanguard-1024
Copy link

Affects PMD Version:6.47.0

Rule:ConstructorCallsOverridableMethod

Please provide the rule name and a link to the rule documentation:
https://pmd.sourceforge.io/pmd-6.48.0/pmd_rules_java_errorprone.html#constructorcallsoverridablemethod

Description:
Hi, we are doing research in testing static analyzer. Our approach found a false negative about the rule ConstructorCallsOverridableMethod.

In the first example below, PMD should have reported a warning at line 4, but not. However, PMD can report the warning at line 3 in the second example. Hence, I think this is a false negative.

First example (False negative)

public class Foo {
  final boolean tag = true;
  public Foo() {
    bar(tag);  // should report a warning at this line
  }
  public void bar(boolean b) {}
}

Second example (Can be detected)

public class Foo {
  public Foo() {
    bar(true);  // should report a warning at this line
  }
  public void bar(boolean b) {}
}

Expected outcome:

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

Running PMD through: [CLI]

@vanguard-1024 vanguard-1024 added the a:false-negative PMD doesn't flag a problematic piece of code label Aug 23, 2022
@adangel adangel changed the title ConstructorCallsOverridableMethod should consider constructor with constants [java] ConstructorCallsOverridableMethod should consider constructor with constants Aug 24, 2022
@adangel adangel changed the title [java] ConstructorCallsOverridableMethod should consider constructor with constants [java] ConstructorCallsOverridableMethod should consider method calls with var access Aug 24, 2022
@adangel adangel modified the milestone: 6.49.0 Aug 24, 2022
@adangel adangel self-assigned this Sep 27, 2022
@adangel adangel added this to the 6.50.0 milestone Sep 27, 2022
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.

2 participants