[java] Update rule MisplacedNullCheck#3545
Conversation
Generated by 🚫 Danger |
|
There are a couple of new false positives: Entry e1 = indexKey[probe];
if (e1 == e || e1 == null)
return probe;Message: "The null check here is misplaced; if the variable 'e1' is null there will be a NullPointerException" There will be no NPE - this code is fine. int UDef = (unfavoredCoding == dflt || unfavoredCoding == null)?1:0;Message: "The null check here is misplaced; if the variable 'unfavoredCoding' is null there will be a NullPointerException" That's wrong - there will be no NPE. if (rep != obj && rep != null) {Message: The null check here is misplaced; if the variable 'rep' is null there will be a NullPointerException https://github.com/openjdk/jdk/tree/jdk-11+28/src/java.base/share/classes/java/lang/Class.java#L1522 if (enclosingClass == this || enclosingClass == null)Message: The null check here is misplaced; if the variable 'enclosingClass' is null there will be a NullPointerException for (Node p = tail; p != node && p != null; p = p.prev)Message: "The null check here is misplaced; if the variable 'p' is null there will be a NullPointerException" if (defaultZone != this &&
defaultZone != null && id.equals(defaultZone.getID())) {Message: "The null check here is misplaced; if the variable 'defaultZone' is null there will be a NullPointerException" if (loader1 == loader2 || loader1 == null
|| (loader2 == null && !loader1MustBeParent)) {Message: "The null check here is misplaced; if the variable 'loader1' is null there will be a NullPointerException" if ((params instanceof NamedCurve) || (params == null)) {Message: "The null check here is misplaced; if the variable 'params' is null there will be a NullPointerException" while (Object.class != searchType && searchType != null) {Message: "The null check here is misplaced; if the variable 'searchType' is null there will be a NullPointerException" |
| /@Image | ||
| satisfies starts-with($var, concat(PrimaryExpression/PrimaryPrefix/Name/@Image, '.'))] | ||
| /PrimaryExpression/PrimaryPrefix/Name | ||
| //InfixExpression[@Operator = '&&'] |
There was a problem hiding this comment.
I think this rule might have been easier to write in Java. There are already utilities for null checks in JavaRuleUtil. But well, this works, so let's keep it.
Part of #2701