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] BigIntegerInstantiation: False Positive with Java 17 and BigDecimal.TWO #4886

Closed
Akromangel opened this issue Mar 25, 2024 · 0 comments · Fixed by #4890
Closed

[java] BigIntegerInstantiation: False Positive with Java 17 and BigDecimal.TWO #4886

Akromangel opened this issue Mar 25, 2024 · 0 comments · Fixed by #4890
Assignees
Labels
a:false-positive PMD flags a piece of code that is not problematic
Milestone

Comments

@Akromangel
Copy link

Akromangel commented Mar 25, 2024

Affects PMD Version:

7.0.0

Rule:

https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_rules_java_performance.html#bigintegerinstantiation

Description:

The rule fails on Java 17.
BigDecimal.TWO was introduced in Java 19.

Code Sample demonstrating the issue:

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
enum Ratio {
  TWO("One to Two", "1:2", new BigDecimal("2"));

    private final String title;
    private final String calculation;
    private final BigDecimal factor;
}

Expected outcome:

PMD reports a violation, but that's wrong. That's a false positive.

Running PMD through: [Gradle]

gradle :pmdMain
@Akromangel Akromangel added the a:false-positive PMD flags a piece of code that is not problematic label Mar 25, 2024
@adangel adangel self-assigned this Mar 25, 2024
@adangel adangel changed the title False Positive failure on Java 17 [java] BigIntegerInstantiation: False Positive with Java 17 and BigDecimal.TWO Mar 25, 2024
@adangel adangel added this to the 7.0.1 milestone Mar 25, 2024
adangel added a commit to adangel/pmd that referenced this issue Mar 25, 2024
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.

2 participants