Skip to content

Module code-analysis

A custom plugin for code analysis which uses Detekt and Sonarqube under the hood.

Download from MavenCentral

// buildSrc/build.gradle.kts

dependencies {
    implementation("com.javiersc.gradle-plugins:code-analysis:$version")
}

Apply

In the root build.gradle.kts

plugins {
    `javiersc-code-analysis`
}

Usage

Completely configured, and it adds automatically the detekt.xml config used by the IDEA plugin, so the IDEA plugin is enabled by default.

Sonarqube configurations

Sonar project key

Two options:

  • codeAnalysis.sonar.projectKey=projectKey (remember to change projectKey with your real key)
  • Set the project key to match ${group}:{project.name}, for example: com.javiersc.semver:semantic-versioning-kmp
Sonar login token

As Gradle property:

codeAnalysis.sonar.login=token

As environment variable:

SONAR_TOKEN

Remember to change token with the real token.

Sonar host url
codeAnalysis.sonar.host.url=url

Remember to change url with the real token. Default https://sonarcloud.io

Sonar organization
codeAnalysis.sonar.organization=org

Remember to change org with the real token.