From ba04f760d23b80a350a9435f603cfbb983c89f60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Stu=CC=88rmer?= Date: Wed, 24 Apr 2024 13:56:34 +0200 Subject: [PATCH] enable static code analysis --- .github/workflows/build.yml | 35 +++++++++++++++++++++++++++++++++++ Ladefuchs/app/build.gradle | 8 +++++++- Ladefuchs/detekt.yml | 14 ++++++++++++++ 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 Ladefuchs/detekt.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b11a01a..74ffbe9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -51,3 +51,38 @@ jobs: path: | Ladefuchs/app/build/outputs/apk/debug/app-debug.apk Ladefuchs/app/build/outputs/apk/release/app-release-unsigned.apk + + testing: + - uses: actions/checkout@v3 + + - name: Set up JDK 17 + uses: actions/setup-java@v1 + with: + java-version: 17 + + - name: Write API key into build config + env: + API_TOKEN: ${{ secrets.API_KEY }} + run: echo apiKey=$API_TOKEN > Ladefuchs/secrets.properties + + - name: Build fw + working-directory: Ladefuchs + run: | + ./gradlew koverXmlReport + + - name: Upload test reports + if: always() + uses: actions/upload-artifact@v3 + with: + name: tests + path: Ladefuchs/build/reports + + - name: Add coverage report to PR + uses: mi-kas/kover-report@v1 + with: + path: ${{ github.workspace }}/Ladefuchs/build/reports/kover/result.xml + token: ${{ secrets.GITHUB_TOKEN }} + title: App Coverage + update-comment: true + min-coverage-overall: 20 + min-coverage-changed-files: 50 diff --git a/Ladefuchs/app/build.gradle b/Ladefuchs/app/build.gradle index ff373a6..c49b9b5 100644 --- a/Ladefuchs/app/build.gradle +++ b/Ladefuchs/app/build.gradle @@ -2,6 +2,8 @@ plugins { id 'com.android.application' id 'kotlin-android' id 'kotlin-parcelize' + id 'io.gitlab.arturbosch.detekt' version '1.22.0' + id 'org.jetbrains.kotlinx.kover' version '0.7.6' } android { @@ -47,8 +49,12 @@ android { namespace 'app.ladefuchs.android' } +// https://detekt.dev/gradle.html +detekt { + config = files("../detekt.yml") +} + dependencies { - implementation fileTree(dir: "libs", include: ["*.jar"]) implementation(platform("org.jetbrains.kotlin:kotlin-bom:$kotlin_version")) implementation 'androidx.core:core-ktx:1.10.1' implementation 'androidx.appcompat:appcompat:1.6.1' diff --git a/Ladefuchs/detekt.yml b/Ladefuchs/detekt.yml new file mode 100644 index 0000000..8a1cd65 --- /dev/null +++ b/Ladefuchs/detekt.yml @@ -0,0 +1,14 @@ +# Find all defined configuration options in the default configuration +# https://github.com/detekt/detekt/blob/main/detekt-core/src/main/resources/default-detekt-config.yml + +naming: + FunctionNaming: + # adjust pattern to support compose function naming + functionPattern: '([A-Za-z][a-zA-Z0-9]*)|(`.*`)' + + TopLevelPropertyNaming: + constantPattern: '[A-Z][_A-Z0-9]*' + +style: + MagicNumber: + active: false