1

I have a Console project and want to disable the rule Console logging should not be used on it. But it seems MSBuild don't get theses exclusions (anything found in Agent logs, or .sonarqube logs) added in project configuration (sonar.issue.ignore.multicriteria).

Rule Key Pattern: csharpsquid:S2228

File Path Pattern:**/MyProject/**/*.*

Do I have to have a configuration file or MSbuild should retreive Sonar configuration for projects ?

For the first project, the runner try to get server rules:

2016-01-29T08:37:36.3162048Z 09:37:36.217 INFO  - -------------  Scan FisrtProject
2016-01-29T08:37:36.3172057Z 09:37:36.288 INFO  - Load server rules
2016-01-29T08:37:36.8185565Z 09:37:36.629 INFO  - Load server rules (done) | time=341ms

But not the others. I thougt that, as the runner has passed once for this rule and this file, these default are not deleted automatically, but should I to find logs about this ?

I try to change sonar.global.exclusions and sonar.exclusions and they are found by the runner.

Fabian N.
  • 3,807
  • 2
  • 23
  • 46
BonOeil
  • 158
  • 2
  • 13

2 Answers2

0

The sonar.exclusions / sonar.global.exclusions are not what you want to use. They are for excluding files from the analysis not rules. To exclude a rule specifically for a project you must define, in SonarQube, a quality profile and remove that rule from the profile, and assign that quality profile to your project. You can copy your standard profile in a new one and remove the rule on the new one, or use the more flexible quality profile inheritance mechanism (QP for consoles apps inherits from the default QP minus the csharpsquid:S2228 rule) Then run the analysis as usual.

Olivier Korach
  • 281
  • 1
  • 4
  • What about sonar.issue.ignore.multicriteria ? When I talk about project, it is visual studio project, in a solution. All theses projects are in the same SonarQube project. I want to disable a rule for one visual studio project, like a directory for the sonarqube project. – BonOeil Feb 02 '16 at 10:20
-1

None of the SonarQube.Issue.* properties can be set by the command line since they are multivalued. Please find the official documentation here.

You can have SonarQube ignore issues on certain components and against certain coding rules. Go to Administration > General Settings > Analysis Scope > Issues.
Note that the properties below can only be set through the web interface because they are multi-valued.

These are the SonarQube issue properties:

  • Ignore Issues on Files - Key: sonar.issue.ignore.allfile
  • Ignore Issues in Blocks - Key: sonar.issue.ignore.block
  • Ignore Issues on Multiple Criteria - Key: sonar.issue.ignore.multicriteria
  • Restrict Scope of Coding Rules - Key: sonar.issue.enforce.multicriteria

If you want to set this property globally for all SonarQube projects then go to the Administration -> Analysis Scope of your SonarQube server:

  1. Browse to the your Sonar instance : http://servername:9000
  2. Login as Admin
  3. Click on Administration
  4. Choose the Analysis tab on the left hand side
  5. Go down to the issues block and look at the "Ignore Issues on Multiple Criteria"

enter image description here

If you want to apply this exclusion for a specific SonarQube project then select the project and then browse the project -> Administration -> Analysis Scope.

Isaiah4110
  • 9,855
  • 1
  • 40
  • 56