if we have code:
@Contract("null, _, _ -> fail")
static void ifNull(Object object, ErrorType errorType, Object... args) throws ServiceException {
if (object == null) {
ExceptionFactory.throwServiceException(errorType, args);
}
}
and
private boolean checkSeqValue(Sequence sequence, @Nonnull Number value) {
...
}
and somewhere:
ifNull(value, ErrorType.NOT_FOUND, "Value for a sequence", "name = " + seqName);
if (checkSeqValue(sequence, value)) {
result = value;
}
then SonarLint plugin shows a Critical bug:
squid:S2637 "@NonNull" values should not be set to null
for checkSeqValue Parameter 2 to this call is marked javax.annotation.Nonnull
but null passed
directly check:
if (value == null) {
throw new ServiceException();
}
if (!isNeedCheck || checkSeqValue(sequence, value)) {
result = value;
}
doesn't give any sonar errors.
is anybody know how make sonar take into consideration @Contract annotation?
SonarLint plugin version 3.3.0.2482
SonarQube 6.0
Intellij idea 2018.1.1
Thanks a lot