@SupressWarnnings for InsufficientBranchCoverage in Sonar doesn't work

Viewed 821

I've already did the steps mentioned in this thread with regards to ignoring the coverage on new code on sonar. Such as adding the @SuppressWarnings on the method or class levels (right above the method/class) w/ the ff. syntax.

@SuppressWarnings("common-java:InsufficientBranchCoverage")
@SuppressWarnings("InsufficientBranchCoverage")
@SuppressWarnings("java:InsufficientBranchCoverage")

However, the Coverage on new Code is still being reported in sonar. Thing is, I've already reached the minimum required code coverage for the entire project as could be seen in this screenshot. enter image description here

Hence I don't need it to be reported alright. This happened when I edited the code and removed the whitespaces and dead code in the project, and it just so happen that the part of the code being reported here not being covered is the thing I could not really have a unit test on.

Here's a snippet of my pom config below.

 <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <!-- Sonar -->
            <plugin>
                <groupId>org.sonarsource.scanner.maven</groupId>
                <artifactId>sonar-maven-plugin</artifactId>
                <version>3.5.0.1254</version>
            </plugin>
            <!-- Code Coverage Report -->
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.8.2</version>
                <executions>
                    <execution>
                        <id>pre-unit-test</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>agent-for-it</id>
                        <goals>
                            <goal>prepare-agent-integration</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>jacoco-site</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>

                </configuration>
            </plugin>
        </plugins>
    </build>

Is there something wrong with my config or declaration,or was the syntax already deprecated?. TIA.

PS: I already tried

this.method() //NOSONAR

and

@SuppressWarnings("all")

@SuppressWarnings("all") is still reporting the code coverage in the Quality Gate. But it did remove the other warnings in the entire class or method. Just not the new code coverage being reported in the scan.

0 Answers
Related