detekt / sonar-detekt

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

How to work with the official Sonar plugin #131

Closed afaucogney closed 4 years ago

afaucogney commented 4 years ago

I use detekt to run with the IDE, then with Danger for the MR comments and also in Sonar. Today I push the configuration with those 2 gradle lines of the sonar plugin.

        property "detekt.sonar.kotlin.config.path", "${rootProject.projectDir}/base/test-kit/config/detekt/detekt-config.yml"
        property "sonar.kotlin.detekt.reportPaths", "${project.buildDir}/reports/detekt/detekt-report.xml"

I just installed for a new projet Sonar 8.x with the new detekt plugin delivered by Sonar MarketPlace. From this project readme, this feel that there is 2 plugins.

Before I did used any detekt plugin.

What are the usage of both ?

How to keep the same config, that either in IDE, MR or Sonar, the dev get same errors ?

arturbosch commented 4 years ago

Hi @afaucogney,

I guess you have two options:

  1. Either use the official sonarqube Kotlin plugin and publish detekt reports via `property "sonar.kotlin.detekt.reportPaths", "${project.buildDir}/reports/detekt/detekt-report.xml".
  2. Or use both our and sonarqube's plugin together with a joint quality profile and detekt.sonar.kotlin.config.path.

Does this answer your question?

afaucogney commented 4 years ago

Thanks supporting me.

What is the advantage of one solution against the other.

I mean, until now, I was not using any detekt independent sonar plugin, just the sonar kotil plugin. By this way, issues are directly managed by my project.

I did some trial with the official detekt plugin, but it complaints about non existing rules at import step, because of version difference.

I like the way to manage all my rules with detekt inside my project, but why will I loose to not use the detekt sonar plugin !

arturbosch commented 4 years ago

Hi,

TBH I haven't used the official plugin to upload detekt findings. Our plugin deduplicates some issues also found by KtLint (detekt-formatting) which the official would not do I think.

Did you find any more reasons to choose one over the other?

I just published sonar-detekt 2.3.0 (will appear in the marketplace in a few days or download it now via GitHub). It will be compatible with detekt 1.14.1 so newer rules can be imported into sonarqube.

Feel free to reopen if you have more questions!