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] RedundantFieldInitializer can not detect a special case for char initialize: char foo = '\0'; #2441

Closed
wuchiuwong opened this issue Apr 25, 2020 · 0 comments · Fixed by #2677
Labels
a:false-negative PMD doesn't flag a problematic piece of code
Milestone

Comments

@wuchiuwong
Copy link

Affects PMD Version:
6.22.0

Rule:
RedundantFieldInitializer

Description:
RedundantFieldInitializer can not detect a special case for char initialize: char foo = '\0';
The reason for the undetectability is that '\0' can't convert to int directly, in value = (int) literal.getImage().charAt(1); in pmd-java-6.22.0-sources.jar!\net\sourceforge\pmd\lang\java\rule\performance\RedundantFieldInitializerRule.java_93
Code Sample demonstrating the issue:

char foo = '\0';

Expected outcome:
false-negative

Running PMD through:
CLI

@wuchiuwong wuchiuwong added the a:bug PMD crashes or fails to analyse a file. label Apr 25, 2020
@oowekyala oowekyala added a:false-negative PMD doesn't flag a problematic piece of code and removed a:bug PMD crashes or fails to analyse a file. labels Apr 25, 2020
@adangel adangel added this to the 6.27.0 milestone Jul 30, 2020
@adangel adangel changed the title [java]RedundantFieldInitializer can not detect a special case for char initialize: char foo = '\0'; [java] RedundantFieldInitializer can not detect a special case for char initialize: char foo = '\0'; Jul 30, 2020
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
3 participants