0

I need to set exclusions for Code coverage exclusions for XSD, lombok and slf4j logger generated classes and data objects

I know SonarQube allows to set coverage exclusions at file level. Is there also a global setting we can use to exclude coverage anlaysis for data objects. As an example.

These classes can be identified by scanning annotation “@XmlAccessorType”, “@XmlRootElement”, “implements Serializable” etc. These classes usually don’t contain any business logic except setters/getters. Also few generated classes have extension of “extends BaseResponseEdge” and “extends BaseResponseMiddle”.

Also Exclude slf4j Logger objects, static constants and final class variables from Integration test coverage.

BTW, I use mvn + jacoco + surefire + failsafe for code coverage implementation

Thanks, Manny

Jeel
  • 2,227
  • 5
  • 23
  • 38
  • See also https://stackoverflow.com/questions/25592437/exclude-setters-and-getters-in-jacoco-code-coverage/ regarding Lombok generated objects – potame Jul 08 '21 at 08:52

1 Answers1

1

You can set exclusions at both the project and global levels.

Since you want to exclude by file contents, take a look at the Ignore Issues section of the docs. It shows you how to ignore issues raised * on files that contain a string matching your regex * between regex-specified start and end markers * from specific rules on file paths matching a pattern

Code coverage exclusions aren't as fine-grained. You can only exclude by file path pattern.

G. Ann - SonarSource Team
  • 22,346
  • 4
  • 40
  • 76