detekt / sonar-detekt

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

Plugin configuration questions #166

Open 4rthurRousseau opened 1 year ago

4rthurRousseau commented 1 year ago

Hello team !

My team and I are working on multiple Java / Kotlin Android projects with a mix of Jetpack Compose and traditional Android projects. We recently integrated the sonar-kotlin plugin (version 2.5.0) into our SonarQube and so far, everything is running perfectly, but now that we're trying to meet different requirements on some projects, wer're having questions / issues about the plugin configuration.

Issues with "Non-Detekt" projects :

Some of our Kotlin projects do not use Detekt and we do not plan on integrating it. However, we have been experiencing crashes in these projects since the day we started specifying the Detekt configuration YAML path in the plugin configuration.

FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':sonarqube'.
Configuration does not exist: /home/jenkins/agent/workspace/[REMOVED]/detekt-configuration.yaml

Is there a way to only use the Detekt configuration if it is present in the project, preventing crashes on projects that do not use Detekt ?

Configuration overlapping :

We have specified a path for "detekt.sonar.kotlin.config.path" in the plugin configuration. We are curious about how the rules defined in the YAML file of each project interact with the rules imported during the plugin addition. What is the impact of this setting and how does it work in conjunction with the predefined Detekt rules ?

Modifying rules for specific projects :

Our aim is to keep all the rules configured at the quality profile level, but we would like to modify some rules for certain projects that use Jetpack Compose (https://detekt.dev/docs/introduction/compose/). We noticed that Detekt offers a "--build-upon-default-config" flag which allows us to specify only the rules we wish to modify. Is it possible to "emulate" this behavior using the Sonar-Kotlin plugin ?

Your advice and support would be greatly appreciated. Thanks a lot for your work on Detekt and its Sonar plugin !

schalkms commented 1 year ago

Hello! Thanks for the kind words. Sorry for the late reply.

ad) Configuration overlapping :

131 and this forum might shed some light into this point.

ad) Modifying rules for specific projects : Detekt allows to pass multiple config files as seen here. The suggestion would be to select the passed configuration files depending on the current environment.

--config, -c
      Path to the config file (path/to/config.yml). Multiple configuration 
      files can be specified with ',' or ';' as separator.

BR