Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sonarqube - what is rule key?

I am trying to change my Jenkins jobs regarding Sonarqube settings. So I opened my Jenkins job configuration, I am seeing something like this

sonar.issue.ignore.multicriteria=e1,e2,e3,e4,e5
sonar.issue.ignore.multicriteria.e1.ruleKey=squid:S00112
sonar.issue.ignore.multicriteria.e1.resourceKey=**/*.java

I am searching for ruleKey "squid:S00112" in Sonarqube documentation, but I am not able to find any reference regarding that.

I need to add a few more rules to ignore. But I am unable to identify the rules rule-key values (like ruleKey=squid:S00112).

like image 604
Sun Avatar asked Sep 19 '18 06:09

Sun


1 Answers

On a SonarQube server, rule key is displayed on the top right corner of the rule description. For example, you can look for squid:S109 in this rule description

SonarQube rule key is composed of repository id : rule id

repository id

Each language analyser create several rule repositories with ids that usually contain the language name, except for the java analyser that oddly use "squid".

For example, this is the list of repository keys existing on sonarcloud.io (source)

LANGUAGE_ID : REPOSITORY_KEY_LIST
abap        : abap, common-abap
c           : c, common-c
cpp         : cpp, common-cpp
cs          : csharpsquid, common-cs
css         : css, common-css, external_stylelint
flex        : flex, common-flex
go          : go, common-go, external_golint, external_govet
java        : squid, common-java, external_checkstyle, external_findsecbugs, external_pmd, external_spotbugs
js          : javascript, common-js, external_eslint_repo
kotlin      : kotlin, common-kotlin, external_android-lint, external_detekt
objc        : objc, common-objc
php         : php, common-php
plsql       : plsql, common-plsql
py          : python, common-py, Pylint
ruby        : ruby, common-ruby, external_rubocop
swift       : swift, common-swift, external_swiftlint
ts          : typescript, common-ts, external_tslint
tsql        : tsql, common-tsql
vbnet       : vbnet, common-vbnet
web         : Web, common-web
xml         : xml, common-xml

rule id

Former rules could have a Pascal Case id like "NoSonar", but now, majority of rules have an id stating by 'S' following by the jira number of the rule from this repository jira.sonarsource.com/browse/RSPEC/

For example, rule id S109 matches with RSPEC-109

Note: rules.sonarsource.com/ also use the RSPEC-109 format in the URL, you could easily convert it to S109.

like image 160
Alban A. - SonarSource Team Avatar answered Oct 11 '22 06:10

Alban A. - SonarSource Team