Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SonarQube Exclude a directory

People also ask

What is Sonar coverage exclusions?

sonar.exclusions will exclude mentioned files or directories from analysis. sonar.coverage.exclusions still exists and will exclude mentioned files or directories from code coverage like in question asked. But it's not mentioned in current documentation.


Try something like this:

sonar.exclusions=src/java/test/**

I'm able to exclude multiple directories using the below config (comma separated folder paths):

sonar.exclusions=system/**, test/**, application/third_party/**, application/logs/**

And while running the sonar runner I got the following in the log:

Excluded sources: 
  system/**
  test/**
  application/third_party/**
  application/logs/**

This will work for your case:

sonar.exclusions=**/src/java/dig/ ** , **/src/java/test/dig/ **

Another configuration option is adding a maven properties sonar.exclusions. Below is a sample pom file with exclusions of static jquery directory and static pdf viewer directory.

<project >
<modelVersion>4.0.0</modelVersion>
<artifactId>my Artifact</artifactId>
<!-- Enviroment variables can be referenced as such: ${env.PATH} -->
<packaging>war</packaging>
<url>http://maven.apache.org</url>

<properties>

    <junit.version>4.9</junit.version>
    <mockito.version>1.9.5</mockito.version>
    <jackson.version>1.9.7</jackson.version>
    <powermock.version>1.5</powermock.version>

    <!--Exclude the files Here-->
    <sonar.exclusions>src/main/webapp/static/jquery_ui/*,src/main/webapp/static/pdf-viewer/*,src/main/webapp/static/pdf-viewer/**,src/main/webapp/static/pdf-viewer/**/*</sonar.exclusions>
</properties>


If we want to skip the entire folder following can be used:

sonar.exclusions=folderName/**/*

And if we have only one particular file just give the complete path.

All the folder which needs to be exclude and be appended here.


Easiest way is to go to the server URL after starting the server(localhost:8080) then login as admin,Go to settings>Exclusions> Source File Exclusions- Add your packages here. Restart the server.


what version of sonar are you using? There is one option called "sonar.skippedModules=yourmodulename".

This will skip the whole module. So be aware of it.