Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Add detekt and ktlint #2532

Merged
merged 10 commits into from
Sep 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@ jobs:
${{ runner.os }}-gradle-
#---------------------------------------------------

#Detekt
- name: Detekt
run: ./gradlew detekt

- name: Upload Detekt Release report to GitHub
uses: actions/upload-artifact@v3
with:
name: detekt-report.html
path: build/reports/detekt/detekt.html
#------------------------------------------------------------------

#Lint
- name: Lint (release)
run: ./gradlew lintRelease
Expand Down
7 changes: 6 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ plugins {
// ./gradlew dependencyUpdates // Simple report in the console
// ./gradlew dependencyUpdates -DoutputFormatter=html,json,xml // Report in console & generate files accordingly
id("com.github.ben-manes.versions") version "0.39.0"

// Run with:
// ./gradlew detekt // Simple report in the console
// ./gradlew detektFormat // To check with enabled auto-correction
id("ivy.lint")
}

tasks {
Expand Down Expand Up @@ -35,4 +40,4 @@ fun isNonStable(version: String): Boolean {
val regex = "^[0-9,.v-]+(-r)?$".toRegex()
val isStable = stableKeyword || regex.matches(version)
return isStable.not()
}
}
8 changes: 7 additions & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,10 @@ dependencies {
implementation("com.google.gms:google-services:4.3.15")

implementation("com.google.firebase:firebase-crashlytics-gradle:2.9.8")
}

implementation(libs.detekt.gradle)

// Make version catalog available in precompiled scripts
// https://github.com/gradle/gradle/issues/15383#issuecomment-1567461389
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
}
19 changes: 19 additions & 0 deletions buildSrc/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
pluginManagement {
repositories {
google()
gradlePluginPortal()
}
}

dependencyResolutionManagement {
repositories {
google()
gradlePluginPortal()
}

versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}
47 changes: 47 additions & 0 deletions buildSrc/src/main/kotlin/ivy.lint.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import io.gitlab.arturbosch.detekt.Detekt
import io.gitlab.arturbosch.detekt.extensions.DetektExtension

plugins {
id("io.gitlab.arturbosch.detekt")
}

configure<DetektExtension> {
source.setFrom(projectDir)
config.setFrom("$rootDir/config/detekt/config.yml")
baseline = file("$rootDir/config/detekt/baseline.yml")
}

tasks.register<Detekt>("detektFormat") {
autoCorrect = true
}

tasks.withType<Detekt> {
// Disable task caching
outputs.upToDateWhen { false }

reports {
html.required.set(true)
sarif.required.set(false)
md.required.set(false)
xml.required.set(false)
txt.required.set(false)
}

include("**/*.kt", "**/*.kts")
exclude("**/resources/**", "**/build/**")

parallel = true

buildUponDefaultConfig = true

allRules = true

// Target version of the generated JVM bytecode. It is used for type resolution.
jvmTarget = "1.8"
ILIYANGERMANOV marked this conversation as resolved.
Show resolved Hide resolved
}

dependencies {
detektPlugins(libs.detekt.ruleset.compiler)
detektPlugins(libs.detekt.ruleset.ktlint)
detektPlugins(libs.detekt.ruleset.compose)
}
10 changes: 10 additions & 0 deletions buildSrc/src/main/kotlin/versionCatalog.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@file:Suppress("Filename")

import org.gradle.accessors.dm.LibrariesForLibs
import org.gradle.api.Project
import org.gradle.kotlin.dsl.the

// Make version catalog available in precompiled scripts
// https://github.com/gradle/gradle/issues/15383#issuecomment-1567461389
val Project.libs: LibrariesForLibs
get() = the<LibrariesForLibs>()
5,618 changes: 5,618 additions & 0 deletions config/detekt/baseline.yml

Large diffs are not rendered by default.

Loading