How exclude getters and setters from Sonar Analysis

May I exclude getters and setters from Sonar Analysis?
My Sonar Analysis sad about this class: Not covered by tests
It is a false positive.

public class Condutor {

private String nome;
private String dataNascimento;

public String getNome() { // NOSONAR
    return nome;
}

public void setNome(String nome) { // NOSONAR
    this.nome = nome;
}

}

Hi Livia,

Just to be sure I understand correctly. You are asking to exclude getters and setters from test coverage?

If so, this is not possible and even if it was I wouldn’t recommend it. Simple getters and setters are used at some point by more complex code. Knowing that no test uses those getters and setters is good to know. It means that you won’t detect if something is broken when this class is refactored.

Cheers,
Nicolas

1 Like

Hi,

In addition to Nicolas’ excellent answer, I’d like to point out that you can exclude the entire file from coverage consideration.

 
Ann

2 Likes

Thanks Nicolas and Ann! I agree!