mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
ObviousNullCheck: exclude constructors
This commit is contained in:
@@ -80,7 +80,7 @@ public class ObviousNullCheckInspection extends AbstractBaseJavaLocalInspectionT
|
||||
@Nullable
|
||||
static NullCheckParameter fromCall(PsiMethodCallExpression call) {
|
||||
PsiMethod method = call.resolveMethod();
|
||||
if (method == null) return null;
|
||||
if (method == null || method.isConstructor()) return null;
|
||||
if (!JavaMethodContractUtil.isPure(method)) return null;
|
||||
List<? extends MethodContract> contracts = JavaMethodContractUtil.getMethodCallContracts(method, call);
|
||||
if (contracts.isEmpty() || contracts.size() > 2) return null;
|
||||
|
||||
@@ -53,4 +53,17 @@ abstract class ObviousNullCheck {
|
||||
if(str == null) throw new IllegalArgumentException();
|
||||
return str;
|
||||
}
|
||||
|
||||
class X {
|
||||
private String foo;
|
||||
|
||||
X(String f) {
|
||||
if(f == null) throw new NullPointerException();
|
||||
this.foo = f;
|
||||
}
|
||||
|
||||
X() {
|
||||
this("");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user