Reputation: 91
I'm wondering if it is possible to add a custom rule or modify an existing rule - as mentioned in https://docs.sonarqube.org/display/DEV/Adding+Coding+Rules - to our SonarCloud instance.
We've setup SonarCloud on a couple of private projects and I want to - for instance - modify rule 'php:S1068 - Unused private fields should be removed". In the framework that we're using, a private field with the name of "$db" shouldn't be marked as 'unused', because that framework uses that variable through reflection.
Is it possible to add/modify such rules in SonarCloud?
Upvotes: 8
Views: 7377
Reputation: 1899
This is the way (see this article):
Upvotes: 0
Reputation: 583
Yes, you actually can do that (partialy)!
Go to "Quality Profiles" of your organization, scroll down to the required-one, click 'triple dot' button at the right of profile and select in drop-down menu "Extend".
Now you can change rules in your extended profile by opening it, selecting the rule you want to change and setting new walue of parameters you want (if possible).
Now, it is possible to apply this profile as new default by selecting "Set as Default" from 'triple dot' menu of that profile:
P.S.: The only trick here is you can only change parameters which are allowed to change
Upvotes: 0
Reputation: 169
AFAIK, you can partly modify (some) rules and you can disable them. I don't know how to add a new rule for a public project and we don't have any private one.
To disable/modify the rule:
Bellow is a screen from the current version. In our project, we have deactivates several Python rules:
Upvotes: 6
Reputation: 524
From SonarCloud Team
For custom rules, this is unfortunately not possible on SonarCloud - yet. (and I don't know when this is available - this is not in our short-term list)
Upvotes: 6