[JavaScript] Ability to overwrite using properties file for rules

564 views
Skip to first unread message

Paul Comanici

unread,
Sep 25, 2017, 4:17:52 PM9/25/17
to SonarQube
Hi,

I have configured an instance of SonarQube and I have a profile set to be used for every project.

Now I want for a specific project to overwrite specific rules. In my case to disable that rule (and others).

Example of my ignore part:



// base config ...

sonar
.issue.ignore.multicriteria=js1,js2


# tab characters should not be used
sonar
.issue.ignore.multicriteria.js1.ruleKey=javascript:S3499
sonar
.issue.ignore.multicriteria.js1.resourceKey=**/*.js
// and other ignored rules


Is there something that I'm not doing right? Is there something wrong on how I updated my properties file?

G. Ann Campbell

unread,
Sep 26, 2017, 10:57:31 AM9/26/17
to SonarQube
Hi,

You have 2 choices here:

* analyze those projects with a different profile which does not include the rules you want disabled
* use exclusions

In general, I advise that exclusions - especially multi-criteria ones - be set through the UI. It's just tough to get them configured correctly manually like you're trying to do.


Ann

Paul Comanici

unread,
Sep 26, 2017, 11:09:53 AM9/26/17
to SonarQube
Thanks Ann for the reply.

I do not want to have new profile as we have a lot of projects and it will be very hard to check what profile I'm updating.

My approach is to have a base profile and every project will update using properties what they want to do specific.

Can you help me with configuring this exception from properties file?

Complete example for my properties file:

sonar.projectKey=PROJ_NAME
sonar.projectName=PROJ_NAME Frontend

sonar.projectVersion=1.34.5

sonar.language=js
sonar.sourceEncoding=UTF-8

# JavaScript sources
sonar.sources=src/js

# Excluded folders
sonar.exclusions=node_modules, src/assets, src/l10n, src/sass

# Tests folder
sonar.tests=test

# Coverage report
sonar.javascript.lcov.reportPath=coverage/lcov.info
sonar.coverage.exclusions=src/js/constants, src/js/reducers, src/js/index.js, src/js/typedef.js

# Minimum duplication lines
sonar.cpd.js.minimumLines=25

sonar.issue.ignore.multicriteria=js1,js2
# Grouping of shorthand declarations together in an object
sonar.issue.ignore.multicriteria.js1.ruleKey=javascript:S3499
sonar.issue.ignore.multicriteria.js1.resourceKey=**/*.js
# Function parameters with default values should be declared after the function parameters without default values
sonar.issue.ignore.multicriteria.js2.ruleKey=javascript:S1788
sonar.issue.ignore.multicriteria.js2.resourceKey=**/*.js



G. Ann Campbell

unread,
Sep 26, 2017, 11:16:59 AM9/26/17
to SonarQube
Hi Paul,

I'd really rather not get into this. I can't count the number of times I've told people that this is really, really hard to get right via hand-coded properties, and they should use the UI instead. Really.


Ann


but you might try putting your key list and resourceKey values in quotes

Paul Comanici

unread,
Sep 26, 2017, 11:33:32 AM9/26/17
to SonarQube
Is there anyone that can help me to overwrite defaults using properties file?
Reply all
Reply to author
Forward
0 new messages