[Codenarc-developer] UnnecessaryEqualityWithNull rule
Brought to you by:
chrismair
From: Chris M. <chr...@ea...> - 2011-06-04 15:06:02
|
The documentation for UnnecessaryEqualityWithNull says The expression object.equals(null) is always false and is unnecessary. The object.equals(null) comparison will always return false, since the object is not null. (If the object is null, the program will throw a NullPointerException). This is the basic contract of the equals() method. But this prints true in the GroovyConsole, rather than throwing a NPE: def x = null println x.equals(null) Any thoughts on what to do with this rule? |