SonarCloud and specific rules for NodeJS project within repository code

950 Views Asked by At

I have standard company Quality Profile for NodeJS TypeScript projects in SonarCloud.
Now to create specific ruleset overwriting some or adding/removing we can use inheritance, create other profile with parent to the other one.
Question is if we can do that specific from the code repository instead of creating additional profile in UI? Like any sonar.rule in properties or any similar option?

1

There are 1 best solutions below

0
On BEST ANSWER

As far as i know, there is no way of maintaining a profile within the repository. But there are other options, when it comes to removing rules. Sonar* allows you to exclude rules on specific criteria, like ignoring a rule for a certain file pattern, or restrict some rules for certain file patterns. (General Settings > Analysis Scope)

UI settings

This would allow to generate a global definition containing all rules, and the deactivation of those rules could be handled within the repository - if you have a mechanism for that, like sonar-project.properties for the default scanners in the project root.

We are making use of it, as our rulesets are not heavily diverging, and some projects decided to deactivate some kind of rules, as they do not fit their purpose. With this we still have some comparability of our projects regarding rulesets, but if there are plenty of rules, this can end up in quiet a lot of work. Furthermore there might be issues with adding new rules, which are just applicable to a small subset of projects.