Skip to content

Commit

Permalink
Add detekt (#131)
Browse files Browse the repository at this point in the history
Closes: #94
  • Loading branch information
134130 authored Jan 5, 2025
1 parent 4fb9d9b commit 5bb6c8e
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 1 deletion.
41 changes: 40 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,46 @@ jobs:
with:
cache-default-branch-only: true

detekt:
permission:
contents: read
security-events: write
runs-on: ubuntu-latest
steps:
# Free GitHub Actions Environment Disk Space
- name: Maximize Build Space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
large-packages: false

# Check out the current repository
- name: Fetch Sources
uses: actions/checkout@v4

# Set up Java environment for the next steps
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 17

# Setup Gradle
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
gradle-home-cache-cleanup: true

- name: Run Detekt
run: ./gradlew detektMain detektTest detektReportMergeSarif --continue

- name: Upload Detekt Report
uses: github/codeql-action/upload-sarif@v3
if: success() || failure()
with:
sarif_file: 'build/reports/detekt/merge.sarif.json'


# Run plugin structure verification along with IntelliJ Plugin Verifier
verify:
name: Verify plugin
Expand Down Expand Up @@ -235,4 +275,3 @@ jobs:
with:
name: pluginVerifier-result
path: ${{ github.workspace }}/build/reports/pluginVerifier

46 changes: 46 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import io.gitlab.arturbosch.detekt.Detekt
import io.gitlab.arturbosch.detekt.DetektCreateBaselineTask
import io.gitlab.arturbosch.detekt.report.ReportMergeTask
import org.jetbrains.changelog.Changelog
import org.jetbrains.changelog.markdownToHTML
import org.jetbrains.intellij.platform.gradle.Constants.Constraints
Expand All @@ -13,6 +16,7 @@ plugins {
alias(libs.plugins.changelog) // Gradle Changelog Plugin
alias(libs.plugins.qodana) // Gradle Qodana Plugin
alias(libs.plugins.kover) // Gradle Kover Plugin
alias(libs.plugins.detekt) // Gradle Detekt Plugin
}

group = providers.gradleProperty("pluginGroup").get()
Expand Down Expand Up @@ -138,6 +142,48 @@ tasks {
}
}

val detektReportMergeSarif by tasks.registering(ReportMergeTask::class) {
output = layout.buildDirectory.file("reports/detekt/merge.sarif.json")
}

allprojects {
apply(plugin = "io.gitlab.arturbosch.detekt")

detekt {
buildUponDefaultConfig = true
baseline = file("$rootDir/config/detekt/baseline.xml")
}

dependencies {
detekt("io.gitlab.arturbosch.detekt:detekt-cli:${rootProject.libs.versions.detekt.get()}")
detekt("io.gitlab.arturbosch.detekt:detekt-formatting:${rootProject.libs.versions.detekt.get()}")
detekt(project(":mise-core"))
detekt(project(":mise-products-goland"))
detekt(project(":mise-products-gradle"))
detekt(project(":mise-products-idea"))
detekt(project(":mise-products-nodejs"))
detekt(project(":mise-products-rider"))
detekt(project(":mise-products-toml"))
}

tasks.withType<Detekt>().configureEach {
jvmTarget = "17"
reports {
xml.required = true
html.required = true
sarif.required = true
md.required = true
}
basePath = rootDir.absolutePath
}
detektReportMergeSarif {
input.from(tasks.withType<Detekt>().map { it.reports.sarif.outputLocation })
}
tasks.withType<DetektCreateBaselineTask>().configureEach {
jvmTarget = "17"
}
}

val runIdeForUnitTests by intellijPlatformTesting.runIde.registering {
task {
jvmArgumentProviders +=
Expand Down
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ gradleIdeaExt = "1.1.9"
kotlin = "2.1.0"
kover = "0.9.0"
qodana = "2024.2.6"
detekt = "1.23.7"

[libraries]
junit = { group = "junit", name = "junit", version.ref = "junit" }
Expand All @@ -18,3 +19,4 @@ gradleIdeaExt = { id = "org.jetbrains.gradle.plugin.idea-ext", version.ref = "gr
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" }
qodana = { id = "org.jetbrains.qodana", version.ref = "qodana" }
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }

0 comments on commit 5bb6c8e

Please sign in to comment.