Random Stuff About Stuff

Exclude Generated Files From Sonar Analysis

January 26, 2015

I use SonarQube to scan my projects and check for issues.  One of the things you don’t want is it reporting on issues in files you didn’t create.  For example I don’t think there’s much point in reporting issues in JAXB generated content.

In Sonar you can exclude these from the scan as follows

1. Log in as administrator

sonar_login

The default password is admin/admin

sonar_login2

2. Click on settings

click_settings

3. Go to Exclusions

sonar_exclusion

4. Go to the issues part of exclusions

sonar_issues

5. Add in the regex that identifies the files you want to skip. For the case of JAXB it’s

.*file was generated by the JavaTM Architecture for XML Binding\(JAXB\).*

sonar_ignore

 You can add as many pattern’s as you like


Written by David Kerwick who lives and works Dublin as a Java Technical Lead.