SonarQube Exclude a directory

前端 未结 13 810
失恋的感觉
失恋的感觉 2020-12-23 02:43

I am trying to exclude a directory from being analyzed by Sonar. I have the following properties defined in my sonar-project.properties file:

so         


        
相关标签:
13条回答
  • 2020-12-23 03:03

    Just to mention that once you excluded the files from Sonar, do the same for Jacoco plugin:

    <configuration>
    <excludes>     
    <exclude>com/acme/model/persistence/entity/TransactionEntity*</exclude>
    <exclude>com/acme/model/persistence/ModelConstants.class</exclude>
    </excludes>
    </configuration> 
    
    0 讨论(0)
  • 2020-12-23 03:06

    add this line to your sonar-project.properties file

    ex: sonar.exclusions=src/*.java be careful if you want to exclude a folder and inside the folder there is a file you must first exclude the files or add the files one by one for example imagine there is a folder like below:

    src/app.java src/controllers/home.java src/services/test.java

    you have to do this: sonar.exclusions=src/app.java,src/controllers/*.java,src/services/*.java

    It worked for me

    0 讨论(0)
  • 2020-12-23 03:06

    This worked for me:

    sonar.exclusions=src/**/wwwroot/**/*.js,src/**/wwwroot/**/*.css
    

    It excludes any .js and .css files under any of the sub directories of a folder "wwwroot" appearing as one of the sub directories of the "src" folder (project root).

    0 讨论(0)
  • 2020-12-23 03:07

    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.

    0 讨论(0)
  • 2020-12-23 03:10

    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>
    

    0 讨论(0)
  • 2020-12-23 03:11

    Try something like this:

    sonar.exclusions=src/java/test/**
    
    0 讨论(0)
提交回复
热议问题