ci: integrate Detekt static analysis tool (#493)
- Add Detekt configuration (`detekt.yml`) with custom rules - Apply Detekt plugin to all subprojects - Configure Detekt tasks in Gradle workflow - Update Gradle dependency versions to include Detekt plugin ## Motivation and Context Enhance static code analysis for improved code quality. ## Breaking Changes No ## Types of changes - [x] CI update - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply. --> - [x] I have read the [MCP Documentation](https://modelcontextprotocol.io) - [x] My code follows the repository's style guidelines - [x] New and existing tests pass locally - [ ] I have added appropriate error handling - [ ] I have added or updated documentation as needed
This commit is contained in:
parent
327b1546db
commit
6dc8b752e0
9 changed files with 65 additions and 6 deletions
1
.github/workflows/codeql.yml
vendored
1
.github/workflows/codeql.yml
vendored
|
|
@ -71,6 +71,7 @@ jobs:
|
|||
:kotlin-sdk:compileKotlinJvm \
|
||||
:integration-test:compileKotlinJvm \
|
||||
:conformance-test:testClasses \
|
||||
detekt \
|
||||
-Pkotlin.incremental=false \
|
||||
--no-daemon --stacktrace --rerun-tasks
|
||||
|
||||
|
|
|
|||
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -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
|
||||
|
|
|
|||
14
.idea/detekt.xml
generated
Normal file
14
.idea/detekt.xml
generated
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DetektPluginSettings">
|
||||
<option name="configurationFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/detekt.yml" />
|
||||
</list>
|
||||
</option>
|
||||
<option name="enableDetekt" value="true" />
|
||||
<option name="enableForProjectResult" value="Accepted" />
|
||||
<option name="redirectChannels" value="true" />
|
||||
<option name="treatAsErrors" value="true" />
|
||||
</component>
|
||||
</project>
|
||||
7
.idea/externalDependencies.xml
generated
Normal file
7
.idea/externalDependencies.xml
generated
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalDependencies">
|
||||
<plugin id="detekt" />
|
||||
<plugin id="com.nbadal.ktlint" />
|
||||
</component>
|
||||
</project>
|
||||
7
.idea/ktlint-plugin.xml
generated
Normal file
7
.idea/ktlint-plugin.xml
generated
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="com.nbadal.ktlint.KtlintProjectSettings">
|
||||
<ktlintMode>DISTRACT_FREE</ktlintMode>
|
||||
<ktlintRulesetVersion>DEFAULT</ktlintRulesetVersion>
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -61,3 +61,12 @@ kotlin {
|
|||
explicitApi = ExplicitApiMode.Strict
|
||||
jvmToolchain(21)
|
||||
}
|
||||
|
||||
tasks.named("detekt").configure {
|
||||
dependsOn(
|
||||
"detektMainJvm",
|
||||
"detektCommonMainSourceSet",
|
||||
"detektTestJvm",
|
||||
"detektCommonTestSourceSet",
|
||||
)
|
||||
}
|
||||
|
|
|
|||
7
detekt.yml
Normal file
7
detekt.yml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
config:
|
||||
validation: true
|
||||
warningsAsErrors: true
|
||||
|
||||
complexity:
|
||||
LongMethod:
|
||||
excludes: ['**Test.kt']
|
||||
|
|
@ -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" }
|
||||
|
|
|
|||
Loading…
Reference in a new issue