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

Add code analyzers #4

Merged
merged 4 commits into from
Aug 10, 2022
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
4 changes: 4 additions & 0 deletions .github/workflows/cinemax-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ jobs:
distribution: temurin
java-version: 11
cache: gradle
- name: Run detekt
run: ./gradlew detekt
- name: Run lint
run: ./gradlew :app:lint
tests:
needs: analyze-code
name: Tests
Expand Down
5 changes: 5 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ android {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
lint {
warningsAsErrors = true
abortOnError = true
checkDependencies = true
}
}

dependencies {
Expand Down
18 changes: 18 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,24 @@ plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.detekt)
}

detekt {
toolVersion = libs.versions.detekt.get()
source = files(rootDir)
config = files("$rootDir/config/detekt/detekt.yml")
buildUponDefaultConfig = true
parallel = true
}

dependencies {
detektPlugins(libs.detekt.formatting)
detektPlugins(libs.kode.detekt.rules.compose)
}

tasks.withType<io.gitlab.arturbosch.detekt.Detekt>().configureEach {
exclude("config/**")
}

tasks.register<Delete>("clean") {
Expand Down
43 changes: 43 additions & 0 deletions config/detekt/detekt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
config:
warningsAsErrors: true

complexity:
LongMethod:
ignoreAnnotated: [ 'Composable' ]
LongParameterList:
functionThreshold: 10
ignoreDefaultParameters: true

naming:
FunctionNaming:
ignoreAnnotated: [ 'Composable' ]
TopLevelPropertyNaming:
constantPattern: '[A-Z][_A-Za-z0-9]*'

style:
MagicNumber:
ignorePropertyDeclaration: true
UnnecessaryAbstractClass:
ignoreAnnotated: [ 'Database', 'Module' ]
UnusedPrivateMember:
ignoreAnnotated: [ 'Preview' ]

compose:
ReusedModifierInstance:
active: true
UnnecessaryEventHandlerParameter:
active: true
ComposableEventParameterNaming:
active: true
ComposableParametersOrdering:
active: true
ModifierHeightWithText:
active: true
ModifierParameterPosition:
active: true
ModifierDefaultValue:
active: true
MissingModifierDefaultValue:
active: true
PublicComposablePreview:
active: true
6 changes: 6 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[versions]
kotlin = "1.7.10"
android-gradle-plugin = "7.2.2"
detekt = "1.21.0"
kode-detekt-rules-compose = "1.1.0"

androidx-compose = "1.2.0"
androidx-compose-compiler = "1.3.0-rc02"
Expand All @@ -25,6 +27,9 @@ androidx-test-ext-junit = { module = "androidx.test.ext:junit", version.ref = "a
androidx-test-espresso-core = { module = "androidx.test.espresso:espresso-core", version.ref = "androidx-test-espresso" }
junit = { module = "junit:junit", version.ref = "junit" }

detekt-formatting = { module = "io.gitlab.arturbosch.detekt:detekt-formatting", version.ref = "detekt" }
kode-detekt-rules-compose = { module = "ru.kode:detekt-rules-compose", version.ref = "kode-detekt-rules-compose" }

[bundles]
androidx-compose = [
"androidx-activity-compose",
Expand All @@ -41,3 +46,4 @@ debug = ["androidx-compose-ui-tooling", "androidx-compose-ui-test-manifest"]
android-application = { id = "com.android.application", version.ref = "android-gradle-plugin" }
android-library = { id = "com.android.library", version.ref = "android-gradle-plugin" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }