Sonarqube - what is rule key?
Asked Answered
W

2

6

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

Warrick answered 19/9, 2018 at 6:17 Comment(0)
E
9

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.

Esperance answered 19/9, 2018 at 21:35 Comment(0)
F
2

You can find your ruleKey for specific rule inside SonarQube server.

Steps: Rules Tab -> Select Specific Rule -> Right top is your RuleKey

In this example, the ruleKey is Web:TableWithoutCaptionCheck

Screenshot: enter image description here

Falsework answered 28/8, 2020 at 10:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.