I’m trying to use sonarcloud and sonarlint to catch more NPE exceptions.
To test this i created a simple service and added some clear problematic code but both sonarcloud and sonarlint don’t see the problem with rule java:S2259 and i can’t understand why!
Example:
@RestController
@RequestMapping(path = "rest/template-java", produces = MediaType.APPLICATION_JSON_VALUE)
@Log4j2
public class TemplateJavaController {
@GetMapping
public String templateJava() {
log.debug("template-java");
String test = null;
boolean a = test.isEmpty();
boolean b = returnNUll().isEmpty();
return "template-java" + a + b;
}
@Nullable
@CheckForNull
private String returnNUll() {
return null;
}
}
IntelliJ actually detect the problem but Sonar now. Other kind of problem are detected so the analysis on the file works and i double checked that the rule java:S2259 is active
Thank you for your help!
New contributor
Nicola Gemo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.