mirror of
https://github.com/openMF/mifos-mobile.git
synced 2026-02-06 11:26:51 +00:00
Initial Detekt, Ktlint and Spotless Setup for Static Analysis (#2671)
This commit is contained in:
parent
8146fce9a8
commit
eb0f4b4f31
69
.github/workflows/master_dev_ci.yml
vendored
69
.github/workflows/master_dev_ci.yml
vendored
@ -12,64 +12,29 @@ jobs:
|
||||
name: Build APK
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checking out repository
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Set up JDK
|
||||
- name: Set Up JDK 1.8
|
||||
uses: actions/setup-java@v1
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: 11
|
||||
distribution: 'zulu'
|
||||
java-version: 17
|
||||
|
||||
# Install NDK
|
||||
# - name: Install NDK
|
||||
# run: echo "y" | sudo ${ANDROID_HOME}/tools/bin/sdkmanager --install "ndk;20.0.5594570" --sdk_root=${ANDROID_SDK_ROOT}
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@v4
|
||||
|
||||
# Update Gradle Permission
|
||||
- name: Change gradlew Permission
|
||||
run: chmod +x gradlew
|
||||
|
||||
# Build App
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew assemble
|
||||
|
||||
# Upload Built APK
|
||||
- name: Upload Build Artifacts
|
||||
uses: actions/upload-artifact@v3.1.3
|
||||
- name: Cache Gradle and build outputs
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
name: mifos-mobile
|
||||
path: app/build/outputs/apk/debug/
|
||||
path: |
|
||||
~/.gradle/caches
|
||||
~/.gradle/wrapper
|
||||
build
|
||||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
|
||||
restore-keys: ${{ runner.os }}-gradle-
|
||||
|
||||
lintCheck:
|
||||
name: Static Analysis
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checking out repository
|
||||
uses: actions/checkout@v4
|
||||
- name: Build With Gradle
|
||||
run: ./gradlew build
|
||||
|
||||
- name: Static Analysis
|
||||
run: ./gradlew lint
|
||||
|
||||
- name: Upload Static Analysis Report For Mifos-Mobile Module
|
||||
uses: actions/upload-artifact@v3.1.3
|
||||
if: failure()
|
||||
with:
|
||||
name: Static Analysis Report
|
||||
path: app/build/reports/
|
||||
|
||||
pmd:
|
||||
name: PMD
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checking out repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: PMD Check
|
||||
run: ./gradlew pmd
|
||||
|
||||
- name: Upload PMD Report
|
||||
uses: actions/upload-artifact@v3.1.3
|
||||
if: failure()
|
||||
with:
|
||||
name: PMD Report
|
||||
path: app/build/reports/
|
||||
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@ -43,6 +43,9 @@ build/
|
||||
# Gradle cache
|
||||
.gradle
|
||||
|
||||
# Kotlin
|
||||
.kotlin
|
||||
|
||||
# Android Studio captures folder
|
||||
captures/
|
||||
|
||||
|
||||
@ -1,13 +1,11 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
buildscript {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath(libs.google.oss.licenses.plugin) {
|
||||
exclude(group = "com.google.protobuf")
|
||||
}
|
||||
|
||||
classpath(libs.spotless.gradle)
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,4 +28,53 @@ plugins {
|
||||
alias(libs.plugins.kotlin.android) apply false
|
||||
alias(libs.plugins.spotbugs) apply false
|
||||
alias(libs.plugins.kotlinMultiplatform) apply false
|
||||
alias(libs.plugins.detekt) apply true
|
||||
alias(libs.plugins.spotless) apply true
|
||||
}
|
||||
|
||||
val detektFormatting = libs.detekt.formatting
|
||||
val twitterComposeRules = libs.twitter.detekt.compose
|
||||
val ktlintVersion = "1.0.1"
|
||||
|
||||
subprojects {
|
||||
apply {
|
||||
plugin("io.gitlab.arturbosch.detekt")
|
||||
plugin("com.diffplug.spotless")
|
||||
}
|
||||
|
||||
tasks.withType<io.gitlab.arturbosch.detekt.Detekt>().configureEach {
|
||||
config.from(rootProject.files("config/detekt/detekt.yml"))
|
||||
reports.xml.required.set(true)
|
||||
reports.html.required.set(true)
|
||||
}
|
||||
|
||||
extensions.configure<com.diffplug.gradle.spotless.SpotlessExtension> {
|
||||
kotlin {
|
||||
target("**/*.kt")
|
||||
targetExclude("**/build/**/*.kt")
|
||||
ktlint(ktlintVersion).editorConfigOverride(
|
||||
mapOf(
|
||||
"android" to "true",
|
||||
),
|
||||
)
|
||||
licenseHeaderFile(rootProject.file("spotless/copyright.kt"))
|
||||
}
|
||||
format("kts") {
|
||||
target("**/*.kts")
|
||||
targetExclude("**/build/**/*.kts")
|
||||
// Look for the first line that doesn't have a block comment (assumed to be the license)
|
||||
licenseHeaderFile(rootProject.file("spotless/copyright.kts"), "(^(?![\\/ ]\\*).*$)")
|
||||
}
|
||||
format("xml") {
|
||||
target("**/*.xml")
|
||||
targetExclude("**/build/**/*.xml")
|
||||
// Look for the first XML tag that isn't a comment (<!--) or the xml declaration (<?xml)
|
||||
licenseHeaderFile(rootProject.file("spotless/copyright.xml"), "(<[^!?])")
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
detektPlugins(detektFormatting)
|
||||
detektPlugins(twitterComposeRules)
|
||||
}
|
||||
}
|
||||
@ -10,6 +10,7 @@ coreKtxVersion = "1.12.0"
|
||||
coreTestingVersion = "2.2.0"
|
||||
coreVersion = "3.5.2"
|
||||
countrycodechooserVersion = "1.0"
|
||||
detekt = "1.23.5"
|
||||
espressoContribVersion = "3.5.1"
|
||||
kotlinxCoroutinesAndroidVersion = "1.6.4"
|
||||
kotlinxCoroutinesTestVersion = "1.7.3"
|
||||
@ -69,6 +70,7 @@ dbflowVersion = "4.2.4"
|
||||
preference = "1.0.0"
|
||||
playServicesVersion = "17.0.1"
|
||||
spotbugs = "4.8.0"
|
||||
spotlessVersion = "6.23.3"
|
||||
material3 = "1.2.1"
|
||||
playServicesCodeScanner = "16.1.0"
|
||||
googleAppCodeScanner = "17.2.0"
|
||||
@ -76,6 +78,7 @@ cameraxVersion = "1.3.1"
|
||||
compose-material = "1.6.8"
|
||||
googleMaps = "4.4.1"
|
||||
turbineVersion = "1.1.0"
|
||||
twitter-detekt-compose = "0.0.26"
|
||||
uihouseVersion = "alpha-2.1"
|
||||
vectordrawableVersion = "1.1.0"
|
||||
zxingVersion = "1.9.13"
|
||||
@ -163,6 +166,10 @@ androidx-camera-view = { group = "androidx.camera", name = "camera-view", versio
|
||||
androidx-camera-core = { group = "androidx.camera", name = "camera-core", version.ref = "cameraxVersion" }
|
||||
google-map-compose = { group = "com.google.maps.android", name = "maps-compose", version.ref = "googleMaps" }
|
||||
|
||||
#Detekt
|
||||
detekt-formatting = { group = "io.gitlab.arturbosch.detekt", name = "detekt-formatting", version.ref = "detekt" }
|
||||
twitter-detekt-compose = { group = "com.twitter.compose.rules", name = "detekt", version.ref = "twitter-detekt-compose" }
|
||||
|
||||
# Dependencies of the included build-logic
|
||||
android-gradlePlugin = { group = "com.android.tools.build", name = "gradle", version.ref = "androidGradlePlugin" }
|
||||
android-tools-common = { group = "com.android.tools", name = "common", version.ref = "androidTools" }
|
||||
@ -178,10 +185,12 @@ androidx-test-ext-junit = { group = "androidx.test.ext", name = "junit", version
|
||||
espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espresso-core" }
|
||||
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
|
||||
zxing = { module = "me.dm7.barcodescanner:zxing", version.ref = "zxingVersion" }
|
||||
spotless-gradle = { group = "com.diffplug.spotless", name = "spotless-plugin-gradle", version.ref = "spotlessVersion" }
|
||||
|
||||
[plugins]
|
||||
android-application = { id = "com.android.application", version.ref = "androidGradlePlugin" }
|
||||
android-library = { id = "com.android.library", version.ref = "androidGradlePlugin" }
|
||||
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
|
||||
gms = { id = "com.google.gms.google-services", version.ref = "gmsPlugin" }
|
||||
hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt" }
|
||||
firebase-crashlytics = { id = "com.google.firebase.crashlytics", version.ref = "firebaseCrashlyticsPlugin" }
|
||||
@ -198,6 +207,7 @@ roborazzi = { id = "io.github.takahirom.roborazzi", version.ref = "roborazzi" }
|
||||
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp"}
|
||||
room = { id = "androidx.room", version.ref = "room" }
|
||||
spotbugs = { id = "com.github.spotbugs", version.ref = "spotbugs" }
|
||||
spotless = { id = "com.diffplug.spotless", version.ref = "spotlessVersion" }
|
||||
kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
|
||||
|
||||
# Plugins defined by this project
|
||||
|
||||
9
spotless/copyright.kt
Normal file
9
spotless/copyright.kt
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
* Copyright $YEAR Mifos Initiative
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* See https://github.com/openMF/mobile-mobile/blob/master/LICENSE.md
|
||||
*/
|
||||
9
spotless/copyright.kts
Normal file
9
spotless/copyright.kts
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
* Copyright $YEAR Mifos Initiative
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* See https://github.com/openMF/mobile-mobile/blob/master/LICENSE.md
|
||||
*/
|
||||
10
spotless/copyright.xml
Normal file
10
spotless/copyright.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright $YEAR Mifos Initiative
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
||||
If a copy of the MPL was not distributed with this file,
|
||||
You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
See https://github.com/openMF/mobile-mobile/blob/master/LICENSE.md
|
||||
-->
|
||||
Loading…
Reference in New Issue
Block a user