sonar-detekt icon indicating copy to clipboard operation
sonar-detekt copied to clipboard

Improve rule description inside SonarQube

Open vsigler opened this issue 4 years ago • 1 comments

It would be great if the rule descriptions insider sonarqube were better than just a single sentence.

For example what is on the website: https://detekt.github.io/detekt/complexity.html#complexcondition

ComplexCondition Complex conditions make it hard to understand which cases lead to the condition being true or false. To improve readability and understanding of complex conditions consider extracting them into well-named functions or variables and call those instead.

Severity: Maintainability

Debt: 20min

Configuration options:

  • threshold (default: 4) - the number of conditions which will trigger the rule

Noncompliant Code:

val str = "foo" val isFoo = if (str.startsWith("foo") && !str.endsWith("foo") && !str.endsWith("bar") && !str.endsWith("_")) { // ... }

Compliant Code: val str = "foo" val isFoo = if (str.startsWith("foo") && hasCorrectEnding()) { // ... }

fun hasCorrectEnding() = return !str.endsWith("foo") && !str.endsWith("bar") && !str.endsWith("_")

What is actually displayed in sonarqube:

Complex conditions should be simplified and extracted into well-named methods if necessary.

You see the usability of the plugin is much lower if developers have to always go to the website to find out what each rule actually means.

vsigler avatar Oct 22 '20 16:10 vsigler

Thanks for the request. This is actually a duplicate of #120 but I will close #120 in favor of this due to having a description :).

arturbosch avatar Oct 31 '20 18:10 arturbosch