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

feat: add detekt Android CI workflow, migrate to ktlint plugin #1122

Merged
merged 8 commits into from
Jul 3, 2024
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
39 changes: 39 additions & 0 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,45 @@ jobs:
path: app/build/reports
retention-days: 30

detekt:
runs-on: ubuntu-latest
timeout-minutes: 30

steps:

- name: Checkout code
uses: actions/checkout@v4
with:
submodules: 'recursive'

- name: Validate Gradle wrapper
uses: gradle/actions/wrapper-validation@v3

- name: Mock files for CI
run: |
rm ./app/google-services.json
cp ./app/google-services-example.json ./app/google-services.json

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'zulu'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3

- name: Check detekt
run: ./gradlew detekt

- name: Upload build reports
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v4
with:
name: detekt-reports
path: app/build/reports
retention-days: 30

androidTest:
runs-on: ubuntu-latest
timeout-minutes: 30
Expand Down
12 changes: 10 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ plugins {
id 'de.mobilej.unmock'
id 'com.google.protobuf'
id "com.google.devtools.ksp"
id "io.gitlab.arturbosch.detekt" version "1.23.3"
id "org.jlleitschuh.gradle.ktlint"
id "io.gitlab.arturbosch.detekt" version "1.23.6"
}

unMock {
Expand Down Expand Up @@ -265,6 +264,10 @@ dependencies {

// MQTT
implementation "org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.5"

//detekt ktlint formatting
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.23.6")

}

ksp {
Expand All @@ -275,3 +278,8 @@ ksp {
repositories {
maven { url "https://jitpack.io" }
}

detekt {
config.setFrom("../config/detekt/detekt.yml")
baseline = file("../config/detekt/detekt-baseline.xml")
}
4,853 changes: 0 additions & 4,853 deletions app/config/ktlint/baseline.xml

This file was deleted.

1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ plugins {
id "org.jetbrains.kotlin.jvm" version "$kotlin_version" apply false
id "com.google.devtools.ksp" version "2.0.0-1.0.22" apply false
id "org.jetbrains.kotlin.plugin.compose" version "$kotlin_version" apply false
id "org.jlleitschuh.gradle.ktlint" version "12.1.1"
}

allprojects {
Expand Down
263 changes: 12 additions & 251 deletions app/detekt-baseline.xml → config/detekt/detekt-baseline.xml

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions config/detekt/detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ complexity:
threshold: 60
LongParameterList:
active: true
functionThreshold: 6
functionThreshold: 12
constructorThreshold: 7
ignoreDefaultParameters: false
ignoreDefaultParameters: true
ignoreDataClasses: true
ignoreAnnotatedParameter: []
MethodOverloading:
Expand Down Expand Up @@ -175,6 +175,7 @@ complexity:
ignoreDeprecated: false
ignorePrivate: false
ignoreOverridden: false
ignoreAnnotated: ['Preview']

coroutines:
active: true
Expand Down Expand Up @@ -331,7 +332,7 @@ naming:
FunctionNaming:
active: true
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**']
functionPattern: '[a-z][a-zA-Z0-9]*'
functionPattern: '[a-zA-Z][a-zA-Z0-9]*'
excludeClassPattern: '$^'
FunctionParameterNaming:
active: true
Expand Down Expand Up @@ -364,7 +365,7 @@ naming:
packagePattern: '[a-z]+(\.[a-z][A-Za-z0-9]*)*'
TopLevelPropertyNaming:
active: true
constantPattern: '[A-Z][_A-Z0-9]*'
constantPattern: '[A-Z][A-Za-z0-9]*'
propertyPattern: '[A-Za-z][_A-Za-z0-9]*'
privatePropertyPattern: '_?[A-Za-z][_A-Za-z0-9]*'
VariableMaxLength:
Expand Down Expand Up @@ -615,7 +616,7 @@ style:
- '1'
- '2'
ignoreHashCodeFunction: true
ignorePropertyDeclaration: false
ignorePropertyDeclaration: true
ignoreLocalVariableDeclaration: false
ignoreConstantDeclaration: true
ignoreCompanionObjectPropertyDeclaration: true
Expand Down Expand Up @@ -738,6 +739,7 @@ style:
UnusedPrivateMember:
active: true
allowedNames: ''
ignoreAnnotated: ['Preview']
UnusedPrivateProperty:
active: true
allowedNames: '_|ignored|expected|serialVersionUID'
Expand Down
3 changes: 0 additions & 3 deletions config/ktlint/baseline.xml

This file was deleted.