[NEW RELEASE] sonar-detekt

Hello,

I’m pleased to announce the first plugin release of sonar-detekt.

Changelog:

  • Rename to sonar-detekt
  • Based on detekt 1.7.4
  • All redundant features to official SonarKotlin plugin got dropped
  • Compatible with SonarKotlin, allows mixing rulesets


https://sonarcloud.io/dashboard?id=detekt_sonar-kotlin


https://github.com/detekt/sonar-kotlin/releases/download/2.0.0-RC1/sonar-detekt-2.0.0-RC1.jar

Hi,

Welcome to the community!

Is this an implicit request to add the plugin to the Marketplace?

 
:smiley:
Ann

Hi Ann,

thank you and yes please :).

Artur

Hi Artur,

Could you provide me a project to test with? Hopefully one that has the necessary reports already generated and ready to import?

 
Thx,
Ann

Hi Ann,

here are the steps to test it on the detekt repository:

  • git clone https://github.com/arturbosch/detekt
  • Install this plugin
  • SonarQube -> Quality Profiles -> Copy Sonar way profile -> Bulk Change -> Add all detekt rules to the copied profile
  • gradle sonar (expects to run sonarqube on localhost:9000; you can change it in the gradle.properties file - e.g. systemProp.sonar.host.url=http://localhost:9000)

Notice that no report needs to be generated as detekt is run programmatically.

PS: You can also test it on the sonar-detekt repository itself (mvn sonar:sonar). However there shouldn’t be any code smells in current master.

Best regards,
Artur

Hi Artur,

Here’s what I’m getting:

FAILURE: Build failed with an exception.

* Where:
Settings file '/home/ganncamp/testProjects/kotlin/detekt/settings.gradle.kts' line: 22

* What went wrong:
Script compilation errors:

  Line 22: plugins {
           ^ Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: 
               public inline operator fun <T : Any, C : NamedDomainObjectContainer<TypeVariable(T)>> TypeVariable(C).invoke(configuration: NamedDomainObjectContainerScope<TypeVariable(T)>.() -> Unit): TypeVariable(C) defined in org.gradle.kotlin.dsl
               public operator fun <T> Closure<TypeVariable(T)>.invoke(): TypeVariable(T) defined in org.gradle.kotlin.dsl
               public operator fun <T> Closure<TypeVariable(T)>.invoke(x: Any?): TypeVariable(T) defined in org.gradle.kotlin.dsl
               public operator fun <T> Closure<TypeVariable(T)>.invoke(vararg xs: Any?): TypeVariable(T) defined in org.gradle.kotlin.dsl
               public operator fun <V> Callable<TypeVariable(V)>.invoke(): TypeVariable(V) defined in org.gradle.kotlin.dsl
               public inline operator fun <reified T> Action<in TypeVariable(T)>.invoke(target: TypeVariable(T)): Unit defined in org.gradle.kotlin.dsl
               public operator fun <T> NamedDomainObjectProvider<TypeVariable(T)>.invoke(action: TypeVariable(T).() -> Unit): Unit defined in org.gradle.kotlin.dsl
               @Incubating public operator fun ArtifactHandler.invoke(configuration: ArtifactHandlerScope.() -> Unit): Unit defined in org.gradle.kotlin.dsl
               @Incubating public operator fun DependencyConstraintHandler.invoke(configuration: DependencyConstraintHandlerScope.() -> Unit): Unit defined in org.gradle.kotlin.dsl
               public inline operator fun <T> ExtraPropertiesExtension.invoke(initialValueProvider: () -> TypeVariable(T)): InitialValueExtraPropertyDelegateProvider<TypeVariable(T)> defined in org.gradle.kotlin.dsl
               public operator fun <T> ExtraPropertiesExtension.invoke(initialValue: TypeVariable(T)): InitialValueExtraPropertyDelegateProvider<TypeVariable(T)> defined in org.gradle.kotlin.dsl
               public operator fun <T> Spec<TypeVariable(T)>.invoke(arg: TypeVariable(T)): Boolean defined in org.gradle.kotlin.dsl
               public inline operator fun TaskContainer.invoke(configuration: TaskContainerScope.() -> Unit): TaskContainer defined in org.gradle.kotlin.dsl

  Line 23:     id("com.gradle.enterprise") version "3.2.1"
               ^ Unresolved reference: id

2 errors

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 3m 11s

BTW, the bureaucratic review looks fine except that it seems odd to me to put an “RC1” into the marketplace. I would expect this to be either “GA” or just plain “2.0.0”…

 
Ann

Hi Ann,

It seems like you are using an older version of Gradle.
Please use ./gradlew sonar inside the detekt repository to build with the newest Gradle version (6.3) via the Gradle Wrapper.

I’ve updated the PR to include just the 2.0.0 release without the RC-1.

Best regards,
Artur

Hi Artur,

I had some time to come back to this & got through an analysis.

In general, this looks good. I have some non-blocking feedback, and I’ve asked for a change to your PR. Once that’s taken care of, I’ll pull the trigger.


  • It seems that you have 2 different rules related to line length:


    I thought for a minute that it might be a duplicate, but they raise different numbers of issues
    Selection_999(051)

    I find this difficult to understand, and suspect users will too.

  • It strikes me that you’re putting what I would consider rule description into your issue messages and (often altho not in this particular case) leaving the descriptions largely blank.


    Fully-fleshed descriptions will help your users understand why they should follow your advice. At the same time, I believe keeping the advice itself (the issue message) short and sweet will help them triage issues efficiently.

  • Complex on what scale? Selection_999(053)
    I encourage you to use secondary messages to indicate what in code increments complexity

  • Similarly, this rule would benefit from making the scale explicit:


    922 what?

  • Perhaps you’ve fallen victim to trimming within SonarQube here, but I find this one rather ironic


    Since everything on the line but trailing spaces is highlighted as the “location” of the problem.

 
Ann

Hi Ann,

thanks for the feedback.
I’ve included your PR suggestion.

For the other feedback, I’ve opened two issues in our repo:

Best regards,
Artur

Hi Artur,

You’re in!

 
:tada:
Ann

1 Like