Closed romani closed 10 years ago
equals(null) seems to be a bad style on its own - for me it is better to write "== null"
Moreover - there is only two possible outcomes of this code - "equals(null)" - false and NPE.
yes it is not a very good but it it not different from example in Doc:
should be refactored to:
String nullString = null;
"My_Sweet_String".equals(nullString);
read it as ""My_Sweet_String".equals(null);"
so should not be a problem, just to be consistent in validation. @isopov , does it make sense ?
After discussion, we decided to not implement this, as null is kind of Literal, and developer have to do variable == null.
Created: 2009-06-21 Creator: Baron Roberts SF issue: 576
http://checkstyle.sourceforge.net/config_coding.html#EqualsAvoidNull
Code:
Violation: "Equals Avoid Null: String literal expressions should be on the left side of an equals comparison."
Expected: no violation