0

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

4

1 に答える 1

0

テストを行ったところですが、実際、エラーは報告されていません。

ただし、問題は Sonar 自体ではなく、Findbugs に起因することに注意してください。Sonar はバグ検出のために外部ツールに依存しているためです。ですから、Findbugs のメーリング リストで質問することをお勧めします。

于 2012-08-30T07:53:58.330 に答える