-
Notifications
You must be signed in to change notification settings - Fork 78
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
Position literals first in String comparisons #415
Comments
|
Hi @nvanderperren I've chosen this as your first issue. It's a pet hate of mine. There's 38 instances of the problem, I'd be happier if you fix them a file at a time and then submit a pull request per file if that's OK? Here's an example in the JHOVE window code: if (_selectedModule.equals ("")) {
return null;
}It should read: if ("".equals(_selectedModule)) {
return null;
}This avoids the code throwing a null pointer exception when Good luck |
|
Thanks @carlwilson, will do! |
|
I think I've solved all 38 occurences |
|
I concur, nice work. |
|
yay! 🎉 |
There are 38 occurrences of this issue
Why is this an issue?
Since: PMD 3.3
Position literals first in comparisons, if the second argument is null then NullPointerExceptions can be avoided, they will just return false.
Example(s):
Codacy's list of all occurrences of the issue can be found here
The text was updated successfully, but these errors were encountered: