Skip to content
This repository has been archived by the owner on Jan 6, 2024. It is now read-only.

Improve rule description inside SonarQube #135

Open
vsigler opened this issue Oct 22, 2020 · 1 comment
Open

Improve rule description inside SonarQube #135

vsigler opened this issue Oct 22, 2020 · 1 comment

Comments

@vsigler
Copy link

vsigler commented Oct 22, 2020

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
Copy link
Member

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants