7

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?

Julian
  • 33,915
  • 22
  • 119
  • 174
  • I sent a request to the SonarCloud team, asking myself the same question. Once answerd, I'l get back to you – Rapster Mar 25 '18 at 21:56

3 Answers3

6

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:

  1. On your organization page, click on 'Quality Profiles'
  2. Select the language you want to alter, and using the 'gear' setting button, copy existing (default) profile and set the new one as default.
  3. You can now look for the rule you want to deactivate / modify in the 'Rules' tab

Bellow is a screen from the current version. In our project, we have deactivates several Python rules: enter image description here

David Střelák
  • 169
  • 1
  • 7
5

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)

Rapster
  • 484
  • 1
  • 5
  • 23
0

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".

Step №1

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).

Step №2

Now, it is possible to apply this profile as new default by selecting "Set as Default" from 'triple dot' menu of that profile:

Step №3


P.S.: The only trick here is you can only change parameters which are allowed to change

Ihor Baklykov
  • 543
  • 7
  • 24