Skip to content

Commit e45c9b6

Browse files
authored
Refactor - [:feature:make-transfer] Applied Spotless & Detekt Compose Rules (openMF#1724)
* Refactor: Applied Spotless & Detekt Compose Rules - :feature:accounts - :feature:auth - :feature:editpassword - :feature:finance * Refactor - [:feature:history] Applied Spotless & Detekt Compose Rules * Refactor - [:feature:home] Applied Spotless & Detekt Compose Rules * Refactor - [:feature:invoices] Applied Spotless & Detekt Compose Rules * Refactor - [:feature:kyc] Applied Spotless & Detekt Compose Rules * Refactor - [:feature:make-transfer] Applied Spotless & Detekt Compose Rules
1 parent 6f87da5 commit e45c9b6

File tree

151 files changed

+2979
-1920
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+2979
-1920
lines changed

.editorconfig

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# https://editorconfig.org/
2+
# This configuration is used by ktlint when spotless invokes it
3+
4+
[*.{kt,kts}]
5+
ij_kotlin_allow_trailing_comma=true
6+
ij_kotlin_allow_trailing_comma_on_call_site=true
7+
ktlint_function_naming_ignore_when_annotated_with=Composable, Test, Preview

.github/workflows/master_dev_ci.yml

+15-14
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,21 @@ jobs:
5252
name: mobile-wallet
5353
path: mifospay/build/outputs/apk/debug/
5454

55-
lintCheck:
56-
name: Static Analysis
57-
runs-on: ubuntu-latest
58-
steps:
59-
- uses: actions/checkout@v2
60-
61-
# Setup JDK 17
62-
- name: Setup JDK 17
63-
uses: actions/setup-java@v1
64-
with:
65-
java-version: 17
66-
67-
- name: Detekt For All Modules
68-
run: ./gradlew detekt
55+
# Turing off detekt check until migration finished
56+
# lintCheck:
57+
# name: Static Analysis
58+
# runs-on: ubuntu-latest
59+
# steps:
60+
# - uses: actions/checkout@v2
61+
#
62+
# # Setup JDK 17
63+
# - name: Setup JDK 17
64+
# uses: actions/setup-java@v1
65+
# with:
66+
# java-version: 17
67+
#
68+
# - name: Detekt For All Modules
69+
# run: ./gradlew detekt
6970

7071
pmd:
7172
name: PMD

build.gradle.kts

+31-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import io.gitlab.arturbosch.detekt.DetektCreateBaselineTask
2-
31
// Top-level build file where you can add configuration options common to all sub-projects/modules.
42
buildscript {
53
dependencies {
64
classpath(libs.google.oss.licenses.plugin) {
75
exclude(group = "com.google.protobuf")
86
}
7+
classpath(libs.spotless.gradle)
98
}
109
}
1110

@@ -28,11 +27,14 @@ plugins {
2827
alias(libs.plugins.kotlin.android) apply false
2928
alias(libs.plugins.detekt)
3029
alias(libs.plugins.detekt.compiler)
31-
alias(libs.plugins.module.graph) apply true // Plugin applied to allow module graph generation
30+
// Plugin applied to allow module graph generation
31+
alias(libs.plugins.module.graph) apply true
32+
alias(libs.plugins.spotless)
3233
}
3334

3435
val detektFormatting = libs.detekt.formatting
3536
val twitterComposeRules = libs.twitter.detekt.compose
37+
val ktlintVersion = "1.0.1"
3638

3739
val reportMerge by tasks.registering(io.gitlab.arturbosch.detekt.report.ReportMergeTask::class) {
3840
output.set(rootProject.layout.buildDirectory.file("reports/detekt/merge.html")) // or "reports/detekt/merge.sarif"
@@ -41,15 +43,38 @@ val reportMerge by tasks.registering(io.gitlab.arturbosch.detekt.report.ReportMe
4143
subprojects {
4244
apply {
4345
plugin("io.gitlab.arturbosch.detekt")
46+
plugin("com.diffplug.spotless")
4447
}
4548

46-
detekt {
49+
tasks.withType<io.gitlab.arturbosch.detekt.Detekt>().configureEach {
4750
config.from(rootProject.files("config/detekt/detekt.yml"))
4851
reports.xml.required.set(true)
52+
finalizedBy(reportMerge)
4953
}
5054

51-
tasks.withType<io.gitlab.arturbosch.detekt.Detekt>().configureEach {
52-
finalizedBy(reportMerge)
55+
extensions.configure<com.diffplug.gradle.spotless.SpotlessExtension> {
56+
kotlin {
57+
target("**/*.kt")
58+
targetExclude("**/build/**/*.kt")
59+
ktlint(ktlintVersion).editorConfigOverride(
60+
mapOf(
61+
"android" to "true",
62+
),
63+
)
64+
licenseHeaderFile(rootProject.file("spotless/copyright.kt"))
65+
}
66+
format("kts") {
67+
target("**/*.kts")
68+
targetExclude("**/build/**/*.kts")
69+
// Look for the first line that doesn't have a block comment (assumed to be the license)
70+
licenseHeaderFile(rootProject.file("spotless/copyright.kts"), "(^(?![\\/ ]\\*).*$)")
71+
}
72+
format("xml") {
73+
target("**/*.xml")
74+
targetExclude("**/build/**/*.xml")
75+
// Look for the first XML tag that isn't a comment (<!--) or the xml declaration (<?xml)
76+
licenseHeaderFile(rootProject.file("spotless/copyright.xml"), "(<[^!?])")
77+
}
5378
}
5479

5580
reportMerge {

config/detekt/detekt.yml

+48-2
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@ style:
805805
NestedClassesVisibility:
806806
active: true
807807
NewLineAtEndOfFile:
808-
active: false # Turning off for current implementation
808+
active: true
809809
NoTabs:
810810
active: false
811811
NullableBooleanCheck:
@@ -936,4 +936,50 @@ style:
936936
WildcardImport:
937937
active: true
938938
excludeImports:
939-
- "java.util.*"
939+
- "java.util.*"
940+
941+
TwitterCompose:
942+
CompositionLocalAllowlist:
943+
active: true
944+
# You can optionally define a list of CompositionLocals that are allowed here
945+
# allowedCompositionLocals: LocalSomething,LocalSomethingElse
946+
CompositionLocalNaming:
947+
active: true
948+
ContentEmitterReturningValues:
949+
active: true
950+
# You can optionally add your own composables here
951+
# contentEmitters: MyComposable,MyOtherComposable
952+
ModifierComposable:
953+
active: true
954+
ModifierMissing:
955+
active: true
956+
ModifierReused:
957+
active: true
958+
ModifierWithoutDefault:
959+
active: true
960+
MultipleEmitters:
961+
active: true
962+
# You can optionally add your own composables here
963+
# contentEmitters: MyComposable,MyOtherComposable
964+
MutableParams:
965+
active: true
966+
ComposableNaming:
967+
active: true
968+
# You can optionally disable the checks in this rule for regex matches against the composable name (e.g. molecule presenters)
969+
# allowedComposableFunctionNames: .*Presenter,.*MoleculePresenter
970+
ComposableParamOrder:
971+
active: true
972+
PreviewNaming:
973+
active: true
974+
PreviewPublic:
975+
active: true
976+
# You can optionally disable that only previews with @PreviewParameter are flagged
977+
# previewPublicOnlyIfParams: false
978+
RememberMissing:
979+
active: true
980+
UnstableCollections:
981+
active: false
982+
ViewModelForwarding:
983+
active: true
984+
ViewModelInjection:
985+
active: true

core/common/src/main/kotlin/org/mifospay/common/Utils.kt

+7-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import android.content.Context
55
import android.content.res.Resources
66
import android.view.inputmethod.InputMethodManager
77
import java.text.NumberFormat
8-
import java.util.*
8+
import java.util.Currency
99

1010
object Utils {
1111

@@ -31,4 +31,10 @@ object Utils {
3131
return accountBalanceFormatter.format(balance)
3232
}
3333

34+
fun <T> List<T>.toArrayList(): ArrayList<T> {
35+
val array: ArrayList<T> = ArrayList()
36+
for (index in this) array.add(index)
37+
return array
38+
}
39+
3440
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Copyright 2024 Mifos Initiative
3+
*
4+
* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
7+
*
8+
* See https://github.com/openMF/mobile-wallet/blob/master/LICENSE.md
9+
*/
10+
package org.mifospay.core.data.domain.usecase.history
11+
12+
import com.mifospay.core.model.domain.Transaction
13+
14+
interface HistoryContract {
15+
interface TransactionsHistoryAsync {
16+
fun onTransactionsFetchCompleted(transactions: List<Transaction>?)
17+
}
18+
}

feature/history/src/main/kotlin/org/mifospay/feature/TransactionsHistory.kt core/data/src/main/java/org/mifospay/core/data/domain/usecase/history/TransactionsHistory.kt

+16-8
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
1-
package org.mifospay.feature
1+
/*
2+
* Copyright 2024 Mifos Initiative
3+
*
4+
* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
7+
*
8+
* See https://github.com/openMF/mobile-wallet/blob/master/LICENSE.md
9+
*/
10+
package org.mifospay.core.data.domain.usecase.history
211

312
import com.mifospay.core.model.domain.Transaction
413
import org.mifospay.core.data.base.TaskLooper
514
import org.mifospay.core.data.base.UseCase.UseCaseCallback
615
import org.mifospay.core.data.base.UseCaseFactory
716
import org.mifospay.core.data.base.UseCaseHandler
8-
import org.mifospay.core.data.domain.usecase.account.FetchAccount
917
import org.mifospay.core.data.domain.usecase.account.FetchAccountTransactions
1018
import javax.inject.Inject
1119

12-
@Suppress("UnusedPrivateProperty")
1320
class TransactionsHistory @Inject constructor(
14-
private val mUsecaseHandler: UseCaseHandler,
21+
private val mUseCaseHandler: UseCaseHandler,
1522
private val fetchAccountTransactionsUseCase: FetchAccountTransactions,
16-
private val mFetchAccountUseCase: FetchAccount
1723
) {
1824
var delegate: HistoryContract.TransactionsHistoryAsync? = null
1925

@@ -31,7 +37,8 @@ class TransactionsHistory @Inject constructor(
3137
}
3238

3339
fun fetchTransactionsHistory(accountId: Long) {
34-
mUsecaseHandler.execute(fetchAccountTransactionsUseCase,
40+
mUseCaseHandler.execute(
41+
fetchAccountTransactionsUseCase,
3542
FetchAccountTransactions.RequestValues(accountId),
3643
object : UseCaseCallback<FetchAccountTransactions.ResponseValue?> {
3744
override fun onSuccess(response: FetchAccountTransactions.ResponseValue?) {
@@ -42,6 +49,7 @@ class TransactionsHistory @Inject constructor(
4249
override fun onError(message: String) {
4350
transactions = null
4451
}
45-
})
52+
},
53+
)
4654
}
47-
}
55+
}

core/data/src/main/java/org/mifospay/core/data/domain/usecase/invoice/FetchInvoice.kt

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ class FetchInvoice @Inject constructor(private val mFineractRepository: Fineract
3131
val clientId = params?.get(0) // "clientId"
3232
val invoiceId = params?.get(1) // "invoiceId"
3333
if (clientId != null && invoiceId != null) {
34-
3534
mFineractRepository.fetchInvoice(clientId, invoiceId)
3635
.observeOn(AndroidSchedulers.mainThread())
3736
.subscribeOn(Schedulers.io())

core/data/src/main/java/org/mifospay/core/data/domain/usecase/invoice/FetchInvoices.kt

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.mifospay.core.data.domain.usecase.invoice
22

3+
import android.util.Log
34
import org.mifospay.core.data.base.UseCase
45
import com.mifospay.core.model.entity.Invoice
56
import org.mifospay.core.data.fineract.repository.FineractRepository
@@ -26,6 +27,7 @@ class FetchInvoices @Inject constructor(private val mFineractRepository: Finerac
2627
.subscribe(object : Subscriber<List<Invoice>>() {
2728
override fun onCompleted() {}
2829
override fun onError(e: Throwable) {
30+
Log.e("Invoices", e.message.toString())
2931
useCaseCallback.onError(e.toString())
3032
}
3133

core/designsystem/src/main/kotlin/org/mifospay/core/designsystem/component/MifosScaffold.kt

+8-5
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,26 @@ import androidx.compose.foundation.layout.RowScope
55
import androidx.compose.material3.FloatingActionButton
66
import androidx.compose.material3.Scaffold
77
import androidx.compose.runtime.Composable
8+
import androidx.compose.ui.Modifier
89
import androidx.compose.ui.graphics.Color
910

1011
@Composable
1112
fun MifosScaffold(
12-
topBarTitle: Int? = null,
1313
backPress: () -> Unit,
14+
modifier: Modifier = Modifier,
15+
topBarTitle: Int? = null,
1416
floatingActionButtonContent: FloatingActionButtonContent? = null,
1517
snackbarHost: @Composable () -> Unit = {},
1618
scaffoldContent: @Composable (PaddingValues) -> Unit,
17-
actions: @Composable RowScope.() -> Unit = {}
19+
actions: @Composable RowScope.() -> Unit = {},
1820
) {
1921
Scaffold(
2022
topBar = {
2123
if (topBarTitle != null) {
2224
MifosTopBar(
2325
topBarTitle = topBarTitle,
2426
backPress = backPress,
25-
actions = actions
27+
actions = actions,
2628
)
2729
}
2830
},
@@ -31,17 +33,18 @@ fun MifosScaffold(
3133
FloatingActionButton(
3234
onClick = content.onClick,
3335
contentColor = content.contentColor,
34-
content = content.content
36+
content = content.content,
3537
)
3638
}
3739
},
3840
snackbarHost = snackbarHost,
3941
content = scaffoldContent,
42+
modifier = modifier,
4043
)
4144
}
4245

4346
data class FloatingActionButtonContent(
4447
val onClick: (() -> Unit),
4548
val contentColor: Color,
46-
val content: (@Composable () -> Unit)
49+
val content: (@Composable () -> Unit),
4750
)

core/ui/build.gradle.kts

-3
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,8 @@ dependencies {
1616
api(projects.core.designsystem)
1717
api(projects.core.model)
1818
api(projects.core.common)
19-
2019
api(libs.androidx.metrics)
2120
api(projects.core.analytics)
22-
api(projects.core.designsystem)
23-
api(projects.core.model)
2421

2522
implementation(libs.accompanist.pager)
2623
implementation(libs.androidx.browser)

core/ui/src/main/kotlin/org/mifospay/core/ui/ScrollableTabRow.kt

+4-11
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ import com.google.accompanist.pager.PagerState
1616
import kotlinx.coroutines.launch
1717
import org.mifospay.core.ui.utility.TabContent
1818

19-
/**
20-
* @author pratyush
21-
* @since 23/3/24
22-
*/
23-
2419
@OptIn(ExperimentalFoundationApi::class)
2520
@Composable
2621
fun MifosScrollableTabRow(
@@ -35,11 +30,10 @@ fun MifosScrollableTabRow(
3530
val scope = rememberCoroutineScope()
3631

3732
ScrollableTabRow(
33+
modifier = modifier,
3834
containerColor = containerColor,
3935
selectedTabIndex = pagerState.currentPage,
4036
edgePadding = edgePadding,
41-
indicator = {},
42-
divider = {},
4337
) {
4438
tabContents.forEachIndexed { index, currentTab ->
4539
Tab(
@@ -59,9 +53,8 @@ fun MifosScrollableTabRow(
5953

6054
HorizontalPager(
6155
count = tabContents.size,
62-
state = pagerState,
63-
modifier = modifier
64-
) { page ->
65-
tabContents.getOrNull(page)?.content?.invoke() ?: Text("Page $page")
56+
state = pagerState
57+
) {
58+
tabContents[it].content.invoke()
6659
}
6760
}

0 commit comments

Comments
 (0)