Sonar showing jacoco filtered code in coverage

I am using SonarQube 9.2 Developer Edition. I have added a filter via annotation to exclude a method from jacoco coverage as mentioned here.

After the change the lines are not counted in Lines to cover. For example,

Before Change

After Change

But in the sonar UI the lines are still shown in red as not covered by tests.

Can let me know how can I get around this? I feel it is a bit confusing for user.

  • Jacoco Version - 0.8.8
  • Sonar Version - 9.2 Developer Edition
  • Java - JDK 11

Hey there.

SonarQube is not involved in producing coverage reports, only in reading them. I would suggest you check to see if the annotation is actually having an effect on the JaCoCo report being produced (before it ever reaches SonarQube)

1 Like

(post deleted by author)

Yes it is a jacoco issue. This is discussed in stackoverflow and in jacoco mailing list.

get() method is excluded. But compiler internally created a method for lambda which is shown in red in the class level report. This seems to be a limitation of the jacoco @Generated annotation.