8

I work on symfony project and I want to exclude some generated code from sonar analytics.

I want to exclude a folder named by this path: src/Application/Sonata.

I tried many possibilities with sonar exclusions but in vain:

sonar.exclusions=src/Application/Sonata/*
sonar.exclusions=src/Application/Sonata/**
sonar.exclusions=src/Application/Sonata/**/*

this is my sonar-project.properties file

# Required metadata
sonar.projectKey=project
sonar.projectName=project
sonar.projectVersion=0.1.3
# Description
sonar.projectDescription=project a base symphony 2
# Encoding of the source code
sonar.sourceEncoding=UTF-8
sonar.exclusions=src/Application/Sonata/**/* ,src/project/Resources/public/js/lib/**/*, src/project/Resources/public/js/jquery.validate.js
agabrys
  • 8,728
  • 3
  • 35
  • 73
  • I need to know what steps did you do. Did you do something like: 1. run a first analyse of the project 2. configure `sonar.exclusions` parameter 3. run a second analyse of the project? – agabrys Feb 02 '18 at 17:41
  • Those are exactly the steps i do. –  Feb 05 '18 at 07:50

2 Answers2

25

After many tests, i found the correct syntax of sonar.exclusions clause:

sonar.exclusions=src/Application/Sonata/**/*,src/Simuleo5BOBundle/Resources/public/js/lib/**/*,src/Simuleo5BOBundle/Resources/public/js/jquery.validate.js
-9

Correctly setting exclusions from properties is difficult to get right, which is why it's not documented. Instead, you should use the UI to set your exclusions.

G. Ann - SonarSource Team
  • 22,346
  • 4
  • 40
  • 76
  • 16
    This is an excuse for bad practices. Lack of documentation is why it is difficult to get it right. – Manzotin Aug 01 '19 at 07:58
  • 1
    In my case, I need to set the exclusions from properties based on different CI stages. I guess more people also need to set exclusions based on some automated jobs. Even though it's difficult to get right, it's our only option. I completely agree with Manzontin on his comment. Also, making something difficult to use is not an excuse to avoid documenting it. – Matruskan Jun 01 '20 at 17:42
  • The UI can't be used in an automated build environment. If it exists for the command line, it should be properly documented, so it can be used correctly. – BardMorgan Aug 27 '21 at 15:14