'Diff' highlighting for code examples and Clean Code Principles

Hello SonarCloud users!

We are pleased to announce two more features to help you get to Clean Code faster.

We are adding highlighting to noncompliant and compliant code examples to make it easier to see what updates are needed:

We have also started adding ‘Clean Code principles’ to rules. They provide information on broader topics related to the issue seen and should help you avoid that and other related issues in future:

We have started with a subset of the rules and will be expanding on this over time.

As ever, any feedback and questions are most welcome.

4 Likes

Hi,

will this also be available for Sonarqube on prem and if with which version ?

Gilbert

1 Like

Hi Gilbert,

These first started appearing on a subset of rules in SonarQube 9.7 for Developer, Enterprise and Data Center editions.

You can see a live example of the new format on SonarQube here (the ‘how can I fix it’ and ‘more info’ tabs): SonarQube

and an example on SonarCloud here (the ‘how to fix it’ and ‘more info’ tabs): https://sonarcloud.io/organizations/sonarsource/rules?open=jssecurity%3AS5883&sonarsourceSecurity=command-injection&tab=why

3 Likes

Hi John,

I develop my own plugin and I’d like to do the same (multiple tabs in rule description, green/red highlighting). Could you please point to a code sample?

Thank you

Regards

Nicolas

1 Like

Hi @Nicolas_Alcaraz,

I’m talking to the team to see if we can get some more information for you.

Best regards

John

Hi Nicolas,

I should have asked this before. Which programming language are you writing a plugin for?

Best regards

John

Hi John,

My boss told me that I cannot publicly tell what the language is and what it is about.
I can just tell you that it is a simple programming language developed internally for our own usage.

Anyway, it should not have any impact on the way to write rule descriptions.

I’m on the latest version of the sonar-plugin-api:

<dependency>
  <groupId>org.sonarsource.api.plugin</groupId>
  <artifactId>sonar-plugin-api</artifactId>
  <version>10.1.0.809</version>
</dependency>

And on SonarQube 10.2.

Thanks for your help

Regards

Nicolas

Hi @Nicolas_Alcaraz ,

Apparently, https://github.com/SonarSource/sonar-php/tree/master/php-custom-rules is a good place to start. It is an example of a simple custom plugin for PHP. It was moved from GitHub - SonarSource/sonar-custom-rules-examples: Shows how to bootstrap a project to write custom rules for PHP, Python, Cobol, RPG. That repo contains more examples for different languages, but they can be outdated.

Good luck!

John

Hi John,

Thanks for the link. But it looks like there is no advanced rule descriptions with multiple tabs, green/red highlighting, etc.

Regards

Nicolas