detekt / sonar-detekt

SonarQube plugin for Kotlin
https://detekt.dev
GNU Lesser General Public License v3.0
493 stars 52 forks source link

Improve rule description inside SonarQube #135

Open vsigler opened 4 years ago

vsigler commented 4 years ago

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.

arturbosch commented 4 years ago

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