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

PMD UseUnderscoresInNumericLiterals rule gives false positives on non-divisible number into even 3 digit parts #1248

Closed
h1alexbel opened this issue Mar 29, 2024 · 3 comments

Comments

@h1alexbel
Copy link
Contributor

According to the latest quilice version at the moment, this code violates PMD UseUnderscoresInNumericLiterals rule:

final List<Integer> expected = new ListOf<>(192_809_275_3);

complaint I've got:

[INFO] PMD: src/test/java/git/tracehub/codereview/action/ReviewIdsTest.java[54-54]: Number 192_809_275_3 should separate 
every third digit with an underscore (UseUnderscoresInNumericLiterals)

this one also will trigger the same PMD complaint:

final List<Integer> expected = new ListOf<>(192_809_2753);

But, it I remove the last digit, which is 3:

final List<Integer> expected = new ListOf<>(192_809_275);

PMD will not complain about the UseUnderscoresInNumericLiterals rule violation.

To me, it looks like a false positive, however, maybe I simply don't understand how to fix my first complaint.

@h1alexbel
Copy link
Contributor Author

@pnatashap could you help here?

@pnatashap
Copy link
Contributor

@h1alexbel correct variant should be

final List<Integer> expected = new ListOf<>(1_928_092_753);

@h1alexbel
Copy link
Contributor Author

@pnatashap now it makes sense. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants