Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to customise rules for SonarCloud (not SonarQube)

Tags:

sonarcloud

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?

like image 833
Juan van den Anker Avatar asked Mar 15 '18 01:03

Juan van den Anker


2 Answers

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

like image 91
David Střelák Avatar answered Sep 18 '22 14:09

David Střelák


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)

like image 44
Rapster Avatar answered Sep 19 '22 14:09

Rapster