Thursday, June 8, 2017

How to filter or exclude files in SonarQube from scanning?



When you have third party Java script libraries in your web app, SonarQube may scan them and report defects. You can exclude it from Scanning in two ways as given below:

1. Add below entry in pom.xml
    <properties>
        <sonar.projectName>${project.groupId}:${project.artifactId}</sonar.projectName>
        <sonar.sources>app,src/main</sonar.sources>
        <sonar.exclusions>app/node_modules/**, src/main/webapp/**, app/dist/**</sonar.exclusions>
        <sonar.tests>src/test</sonar.tests>
     </properties>







2. You can also apply exclusions in SonarQube server as well, steps below
  1. Go to sonarQube, select the project you need.
  2. Go to administration,
  3. Click on general settings,
  4. Click on analysis scope
  5. click on files, add files in textbox of Source file exclusions.

    No comments:

    Post a Comment