We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Created: 2009-06-21 Creator: Baron Roberts SF issue: 576
http://checkstyle.sourceforge.net/config_coding.html#EqualsAvoidNull
Code:
String foo = "sdgs"; boolean b = foo.equals(null);
Violation: "Equals Avoid Null: String literal expressions should be on the left side of an equals comparison."
Expected: no violation
The text was updated successfully, but these errors were encountered:
equals(null) seems to be a bad style on its own - for me it is better to write "== null"
Sorry, something went wrong.
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.
No branches or pull requests
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
The text was updated successfully, but these errors were encountered: