I'm having a problem with violation in Sonar to find a basic problem in some codes that we have in my company. Below there is a test class that represents the situation that I want to clarify:
import entity.Cidade;
public class TesteSonar {
public void testarSonar() {
Cidade cidade = testarSonar2();
cidade.getEstado();
}
public Cidade testarSonar2() {
return null;
}
}
In this class, we have the situation where the variable "cidade" receives the return of the method "testarSonar2()" that is null, and after that I use a action from this object. It's obvious that will throw a NullPointerException. My question is: Why findbugs didn't catch this kind of problem?
This situation points to a credibility problem in Sonar in the results that I receive from the tool. Could anyone help to understand why this is happing this way?
Thank's
Alexandre from Brazil