Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding detektAll gradle task. #43

Merged
merged 2 commits into from
Apr 29, 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
2 changes: 1 addition & 1 deletion .github/workflows/android_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
run: ./gradlew test

- name: Lint Checks
run: ./gradlew detekt lintKotlin lint
run: ./gradlew detektAll lintKotlin lint
21 changes: 21 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ buildscript {
plugins {
// https://github.com/jeremymailen/kotlinter-gradle/releases
id("org.jmailen.kotlinter") version "3.13.0" apply false
id("io.gitlab.arturbosch.detekt").version(libs.versions.detektGradlePlugin)
}

apply(from = "buildscripts/githooks.gradle")
Expand All @@ -41,3 +42,23 @@ afterEvaluate {
dependsOn(":installGitHooks")
}
}

tasks {
/**
* The detektAll tasks enables parallel usage for detekt so if this project
* expands to multi module support, detekt can continue to run quickly.
*
* https://proandroiddev.com/how-to-use-detekt-in-a-multi-module-android-project-6781937fbef2
*/
@Suppress("UnusedPrivateMember")
val detektAll by registering(io.gitlab.arturbosch.detekt.Detekt::class) {
parallel = true
setSource(files(projectDir))
include("**/*.kt")
include("**/*.kts")
exclude("**/resources/**")
exclude("**/build/**")
config.setFrom(files("$rootDir/config/detekt/detekt.yml"))
buildUponDefaultConfig = false
}
}
5 changes: 3 additions & 2 deletions documentation/StaticAnalysis.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ This project leverages static analysis to ensure that the codebase meets certain

[Detekt](https://github.com/detekt/detekt) is a static analysis tool that checks for code smells. Examples include magic numbers, complicated conditionals, long methods, long parameter lists, and so much more. It is highly configurable, and if you choose to turn off any checks or customize thresholds you can do so in the [config file](/config/detekt/detekt.yml).

To run a detekt validation, use the following Gradle command:
To run a detekt validation, use the one of the following Gradle commands:

```
./gradlew detekt
./gradlew detekt # Runs over each module synchronously
./gradlew detektAll # Runs over each module in parallel.
```

## Ktlint
Expand Down
2 changes: 1 addition & 1 deletion git-hooks/pre-push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
echo "Running static analysis."

./gradlew lintKotlin
./gradlew detekt
./gradlew detektAll
Loading