inor
inor

Reputation: 2846

Why does it seem like Sonar is ignoring @SuppressWarnings

In my Spring Boot application I have placed the annotation:

 @SuppressWarnings("PMD.EmptyMethodInAbstractClassShouldBeAbstract")

However it seems Sonar is ignoring it as I'm still getting:

Empty method com.mycompany.DefaultService.validateData(String, PrimaryView, int, ServiceHelper) could be declared abstract

I've also tried placing the //NOPMD comment on the line and for that I'm getting:

 Remove usage of this "NOPMD" suppression comment filter.      NEW      squid:S1310

I'm new to Spring Boot, and I don't even see any Sonar plugins being specified in any of my POM files... Is it possible that my project is using an old version of Sonar and that's why these annotations/comments have no effect?

To invoke Sonar I'm using th following command:

mvn clean install sonar:sonar -DskipTests=true -Dsonar.language=java -Dsonar.analysis.mode=preview -Dsonar.host.url=http://susday10058.corp.mycompany.com:9000

I've also tried invoking it with -Dsonar.excludeMarker=NOPMD but that id not work either.

What am I missing?

Upvotes: 0

Views: 1226

Answers (1)

agabrys
agabrys

Reputation: 9126

You should use SonarQube identifiers.

Change:

@SuppressWarnings("PMD.EmptyMethodInAbstractClassShouldBeAbstract")

to:

@SuppressWarnings("pmd:EmptyMethodInAbstractClassShouldBeAbstract")

Identifiers are visible in the right upper corner:

pmd:EmptyMethodInAbstractClassShouldBeAbstract description

Upvotes: 1

Related Questions