Affects PMD Version: pmd:3.26.0
Rule: LiteralsFirstInComparisonsRule
Please provide the rule name and a link to the rule documentation:
https://pmd.github.io/pmd/pmd_rules_java_bestpractices.html#literalsfirstincomparisons
Description:
It is not found on the constant.
Is this indented correctly?
After briefly reviewing the code, I don't see any filtering, so this might be accidental.
A reference is always a potential NPE
, in my opinion.
Therefore, the raw string literal should always come first.
Code Sample demonstrating the issue:
static class Foo { private static final String FOO = null; public static void bar(String _null) { String _null2 = null; FOO.equals("RAW"); // not reported -> false-negative? _null.equals("RAW"); // is reported _null2.equals("RAW"); // is reported } }
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4