diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index fba2019..4657da9 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -71,6 +71,7 @@ jobs: :kotlin-sdk:compileKotlinJvm \ :integration-test:compileKotlinJvm \ :conformance-test:testClasses \ + detekt \ -Pkotlin.incremental=false \ --no-daemon --stacktrace --rerun-tasks diff --git a/.gitignore b/.gitignore index a8c18dd..805579c 100644 --- a/.gitignore +++ b/.gitignore @@ -11,13 +11,15 @@ build/ .idea/compiler.xml .idea/libraries/ .idea -!.idea/icon.png *.iws *.iml *.ipr out/ !**/src/main/**/out/ !**/src/test/**/out/ +!.idea/icon.png +!.idea/detekt.xml +!.idea/externalDependencies.xml ### Kotlin ### .kotlin diff --git a/.idea/detekt.xml b/.idea/detekt.xml new file mode 100644 index 0000000..a408ca9 --- /dev/null +++ b/.idea/detekt.xml @@ -0,0 +1,14 @@ + + + + + + \ No newline at end of file diff --git a/.idea/externalDependencies.xml b/.idea/externalDependencies.xml new file mode 100644 index 0000000..0a081df --- /dev/null +++ b/.idea/externalDependencies.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/.idea/ktlint-plugin.xml b/.idea/ktlint-plugin.xml new file mode 100644 index 0000000..e8bd90c --- /dev/null +++ b/.idea/ktlint-plugin.xml @@ -0,0 +1,7 @@ + + + + DISTRACT_FREE + DEFAULT + + \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index bcdf96f..2161a96 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,8 @@ +import dev.detekt.gradle.extensions.FailOnSeverity + plugins { id("mcp.dokka") + alias(libs.plugins.detekt) alias(libs.plugins.ktlint) alias(libs.plugins.kover) } @@ -18,6 +21,13 @@ dependencies { subprojects { apply(plugin = "org.jlleitschuh.gradle.ktlint") apply(plugin = "org.jetbrains.kotlinx.kover") + apply(plugin = "dev.detekt") + + detekt { + config = files("$rootDir/detekt.yml") + buildUponDefaultConfig = true + failOnSeverity.set(FailOnSeverity.Never) + } } dokka { diff --git a/buildSrc/src/main/kotlin/mcp.multiplatform.gradle.kts b/buildSrc/src/main/kotlin/mcp.multiplatform.gradle.kts index a676db7..f3d4616 100644 --- a/buildSrc/src/main/kotlin/mcp.multiplatform.gradle.kts +++ b/buildSrc/src/main/kotlin/mcp.multiplatform.gradle.kts @@ -61,3 +61,12 @@ kotlin { explicitApi = ExplicitApiMode.Strict jvmToolchain(21) } + +tasks.named("detekt").configure { + dependsOn( + "detektMainJvm", + "detektCommonMainSourceSet", + "detektTestJvm", + "detektCommonTestSourceSet", + ) +} diff --git a/detekt.yml b/detekt.yml new file mode 100644 index 0000000..f9eba19 --- /dev/null +++ b/detekt.yml @@ -0,0 +1,7 @@ +config: + validation: true + warningsAsErrors: true + +complexity: + LongMethod: + excludes: ['**Test.kt'] diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index fed638b..5b6b087 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,13 +1,14 @@ [versions] # plugins version -kotlin = "2.2.21" -dokka = "2.1.0" atomicfu = "0.29.0" -ktlint = "14.0.1" -kover = "0.9.4" -netty = "4.2.9.Final" -mavenPublish = "0.35.0" binaryCompatibilityValidatorPlugin = "0.18.1" +detekt = "2.0.0-alpha.1" +dokka = "2.1.0" +kotlin = "2.2.21" +kover = "0.9.4" +ktlint = "14.0.1" +mavenPublish = "0.35.0" +netty = "4.2.9.Final" openapi-generator = "7.18.0" # libraries version @@ -69,6 +70,7 @@ ktor-client-cio = { group = "io.ktor", name = "ktor-client-cio", version.ref = " ktor-server-cio = { group = "io.ktor", name = "ktor-server-cio", version.ref = "ktor" } [plugins] +detekt = { id = "dev.detekt", version.ref = "detekt" } kotlinx-binary-compatibility-validator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "binaryCompatibilityValidatorPlugin" } kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" } ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint" }