diff --git a/README.md b/README.md index 52979c2..e77d283 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Kotlin ```kotlin dependencies { - implementation("com.androidstudy.daraja:daraja:2.0.1") + implementation("com.androidstudy.daraja:daraja:2.0.2") } ``` @@ -20,7 +20,7 @@ Groovy ```groovy dependencies { - implementation 'com.androidstudy.daraja:daraja:2.0.1' + implementation 'com.androidstudy.daraja:daraja:2.0.2' } ``` diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 3de8a6f..06aacf5 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -22,6 +22,7 @@ android { targetSdk = AndroidSdk.targetSdkVersion versionCode = AndroidSdk.versionCode versionName = AndroidSdk.versionName + multiDexEnabled = true vectorDrawables.useSupportLibrary = true testInstrumentationRunner = "com.androidstudy.mpesa.runner.MockTestRunner" } @@ -65,6 +66,7 @@ android { isMinifyEnabled = true } } + namespace = "com.androidstudy.mpesa" } kapt { diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 0696953..958bdbe 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,7 +1,6 @@ + xmlns:tools="http://schemas.android.com/tools"> @@ -16,7 +15,8 @@ + android:label="@string/title_activity_payment" + android:exported="true"> diff --git a/app/src/main/java/com/androidstudy/mpesa/ui/PaymentActivity.kt b/app/src/main/java/com/androidstudy/mpesa/ui/PaymentActivity.kt index 8de09fc..ce20b3a 100644 --- a/app/src/main/java/com/androidstudy/mpesa/ui/PaymentActivity.kt +++ b/app/src/main/java/com/androidstudy/mpesa/ui/PaymentActivity.kt @@ -75,7 +75,13 @@ class PaymentActivity : AppCompatActivity() { } else { // initiate payment showProgressDialog() - daraja.initiatePayment(token, phoneNumber, amount.toString(), AppUtils.generateUUID(), "Payment") { darajaResult -> + daraja.initiatePayment( + token, + phoneNumber, + amount.toString(), + AppUtils.generateUUID(), + "Payment" + ) { darajaResult -> dismissProgressDialog() when (darajaResult) { is DarajaResult.Success -> { diff --git a/build.gradle.kts b/build.gradle.kts index 2d20467..002ba32 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -34,7 +34,7 @@ allprojects { } buildscript { - val kotlinVersion by extra("1.5.21") + val kotlinVersion by extra("1.6.21") val jacocoVersion by extra("0.2") val nexusPublishVersion by extra("1.1.0") diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt index 4a101c1..d9472dc 100644 --- a/buildSrc/src/main/kotlin/Dependencies.kt +++ b/buildSrc/src/main/kotlin/Dependencies.kt @@ -1,52 +1,52 @@ object Versions { // Material and androidX - const val material = "1.3.0-alpha02" - const val constraintLayout = "2.0.1" + const val material = "1.9.0-alpha01" + const val constraintLayout = "2.1.4" // Firebase const val firebase = "26.2.0" //Networking const val retrofit = "2.9.0" - const val okhttp = "4.8.1" - const val loggingInterceptor = "4.8.1" + const val okhttp = "4.10.0" + const val loggingInterceptor = "4.10.0" // Lifecycle - const val lifecycle = "2.2.0" + const val lifecycle = "2.6.0-beta01" // Logging - debug builds - const val timber = "4.7.1" - const val leakCanary = "2.4" - const val chucker = "3.4.0" + const val timber = "5.0.1" + const val leakCanary = "2.10" + const val chucker = "3.5.2" // Kotlin - const val kotlinVersion = "1.5.21" - const val coreKtx = "1.5.0-alpha02" + const val kotlinVersion = "1.8.0" + const val coreKtx = "1.10.0-alpha02" // Gradle Plugins - const val ktlint = "10.1.0" - const val detekt = "1.18.0" - const val spotless = "5.9.0" + const val ktlint = "11.2.0" + const val detekt = "1.22.0" + const val spotless = "6.15.0" const val jacoco = "0.8.4" - const val dokka = "1.5.0" - const val gradleVersionsPlugin = "0.29.0" + const val dokka = "1.7.20" + const val gradleVersionsPlugin = "0.45.0" // tests const val junit = "4.13" - const val espresso = "3.3.0" - const val roboelectric = "4.4-beta-1" - const val androidXJUnit = "1.1.1" - const val truth = "1.0.1" - const val mockWebServer = "4.8.1" - const val androidXTestCore = "1.3.0" - const val runner = "1.3.0" - const val rules = "1.3.0" + const val espresso = "3.5.1" + const val roboelectric = "4.9.2" + const val androidXJUnit = "1.1.5" + const val truth = "1.1.3" + const val mockWebServer = "4.10.0" + const val androidXTestCore = "1.5.0" + const val runner = "1.5.2" + const val rules = "1.5.0" const val archComponentTest = "2.1.0" - const val kakao = "2.3.4" + const val kakao = "2.4.0" const val mockK = "1.10.0" const val liveDataTesting = "1.1.2" - const val kotlinxCoroutines = "1.2.1" + const val kotlinxCoroutines = "1.6.4" } object BuildPlugins { @@ -86,7 +86,7 @@ object Libraries { "com.squareup.okhttp3:logging-interceptor:${Versions.loggingInterceptor}" // Lifecycle - const val lifecycle = "androidx.lifecycle:lifecycle-extensions:${Versions.lifecycle}" + const val lifecycle = "androidx.lifecycle:lifecycle-runtime-ktx:${Versions.lifecycle}" // Debug - for debug builds only const val timber = "com.jakewharton.timber:timber:${Versions.timber}" @@ -124,7 +124,7 @@ object BuildModules { object AndroidSdk { const val minSdkVersion = 16 - const val compileSdkVersion = 30 + const val compileSdkVersion = 33 const val targetSdkVersion = compileSdkVersion const val versionCode = 1 const val versionName = "1.0" diff --git a/daraja/build.gradle.kts b/daraja/build.gradle.kts index 468581f..b24c6ea 100644 --- a/daraja/build.gradle.kts +++ b/daraja/build.gradle.kts @@ -49,6 +49,7 @@ android { isMinifyEnabled = false } } + namespace = "com.androidstudy.daraja" } dependencies { @@ -76,7 +77,7 @@ tasks { isFailOnError = false dependsOn(android.libraryVariants.toList().last().javaCompileProvider) - if (! project.plugins.hasPlugin("org.jetbrains.kotlin.android")) { + if (!project.plugins.hasPlugin("org.jetbrains.kotlin.android")) { setSource(sourceFiles) } android.bootClasspath.forEach { classpath += project.fileTree(it) } diff --git a/daraja/src/main/AndroidManifest.xml b/daraja/src/main/AndroidManifest.xml index 1e4cc34..cc947c5 100644 --- a/daraja/src/main/AndroidManifest.xml +++ b/daraja/src/main/AndroidManifest.xml @@ -1 +1 @@ - + diff --git a/daraja/src/main/java/com/androidstudy/daraja/Daraja.kt b/daraja/src/main/java/com/androidstudy/daraja/Daraja.kt index 0d5b42a..ae7b83d 100644 --- a/daraja/src/main/java/com/androidstudy/daraja/Daraja.kt +++ b/daraja/src/main/java/com/androidstudy/daraja/Daraja.kt @@ -15,11 +15,13 @@ */ package com.androidstudy.daraja -import com.androidstudy.daraja.callback.* -import com.androidstudy.daraja.util.TransactionType +import com.androidstudy.daraja.callback.DarajaCallback +import com.androidstudy.daraja.callback.DarajaPaymentCallback +import com.androidstudy.daraja.callback.DarajaResult import com.androidstudy.daraja.data.model.AccessToken import com.androidstudy.daraja.data.model.PaymentResult import com.androidstudy.daraja.data.repo.DarajaRepository +import com.androidstudy.daraja.util.TransactionType /** * Creates Mpesa Payment Payload Details @@ -42,7 +44,14 @@ object Daraja { repo.accessToken.enqueue(DarajaCallback(callback)) } - fun initiatePayment(token: String, phoneNumber: String, amount: String, accountReference: String, description: String, callback: ((darajaResult: DarajaResult) -> Unit)) { + fun initiatePayment( + token: String, + phoneNumber: String, + amount: String, + accountReference: String, + description: String, + callback: ((darajaResult: DarajaResult) -> Unit) + ) { repo.initiatePayment( token = token, phoneNumber = phoneNumber, diff --git a/daraja/src/main/java/com/androidstudy/daraja/callback/DarajaPaymentCallback.kt b/daraja/src/main/java/com/androidstudy/daraja/callback/DarajaPaymentCallback.kt index a18efaa..2a51094 100644 --- a/daraja/src/main/java/com/androidstudy/daraja/callback/DarajaPaymentCallback.kt +++ b/daraja/src/main/java/com/androidstudy/daraja/callback/DarajaPaymentCallback.kt @@ -48,7 +48,6 @@ class DarajaPaymentCallback( val error = gson.fromJson(response.errorBody()?.string(), ErrorResponse::class.java) callback.invoke(DarajaResult.Failure(false, DarajaException(error))) } catch (e: IOException) { - e.printStackTrace() callback.invoke(DarajaResult.Failure(false, DarajaException("${response.code()}"))) } } diff --git a/detekt.yml b/detekt.yml index e29d55d..baadae8 100644 --- a/detekt.yml +++ b/detekt.yml @@ -1,85 +1,204 @@ build: maxIssues: 0 + excludeCorrectable: false weights: # complexity: 2 # LongParameterList: 1 # style: 1 # comments: 1 +config: + validation: true + warningsAsErrors: false + checkExhaustiveness: false + # when writing own rules with new properties, exclude the property path e.g.: 'my_rule_set,.*>.*>[my_property]' + excludes: '' + processors: active: true exclude: + - 'DetektProgressListener' + # - 'KtFileCountProcessor' + # - 'PackageCountProcessor' + # - 'ClassCountProcessor' # - 'FunctionCountProcessor' # - 'PropertyCountProcessor' - # - 'ClassCountProcessor' - # - 'PackageCountProcessor' - # - 'KtFileCountProcessor' + # - 'ProjectComplexityProcessor' + # - 'ProjectCognitiveComplexityProcessor' + # - 'ProjectLLOCProcessor' + # - 'ProjectCLOCProcessor' + # - 'ProjectLOCProcessor' + # - 'ProjectSLOCProcessor' + # - 'LicenseHeaderLoaderExtension' console-reports: active: true exclude: - # - 'ProjectStatisticsReport' - # - 'ComplexityReport' - # - 'NotificationReport' - # - 'FindingsReport' - # - 'BuildFailureReport' + - 'ProjectStatisticsReport' + - 'ComplexityReport' + - 'NotificationReport' + - 'FindingsReport' + - 'FileBasedFindingsReport' + # - 'LiteFindingsReport' + +output-reports: + active: true + exclude: + # - 'TxtOutputReport' + # - 'XmlOutputReport' + # - 'HtmlOutputReport' + # - 'MdOutputReport' + +comments: + active: true + AbsentOrWrongFileLicense: + active: false + licenseTemplateFile: 'license.template' + licenseTemplateIsRegex: false + CommentOverPrivateFunction: + active: false + CommentOverPrivateProperty: + active: false + DeprecatedBlockTag: + active: false + EndOfSentenceFormat: + active: false + endOfSentenceFormat: '([.?!][ \t\n\r\f<])|([.?!:]$)' + KDocReferencesNonPublicProperty: + active: false + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + OutdatedDocumentation: + active: false + matchTypeParameters: true + matchDeclarationsOrder: true + allowParamOnConstructorProperties: false + UndocumentedPublicClass: + active: false + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + searchInNestedClass: true + searchInInnerClass: true + searchInInnerObject: true + searchInInnerInterface: true + searchInProtectedClass: false + UndocumentedPublicFunction: + active: false + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + searchProtectedFunction: false + UndocumentedPublicProperty: + active: false + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + searchProtectedProperty: false complexity: active: true - ComplexCondition: + CognitiveComplexMethod: active: false + threshold: 15 + ComplexCondition: + active: true threshold: 4 ComplexInterface: - active: true - threshold: 10 - includeStaticDeclarations: false - ComplexMethod: active: false threshold: 10 + includeStaticDeclarations: false + includePrivateDeclarations: false + ignoreOverloaded: false + CyclomaticComplexMethod: + active: true + threshold: 15 ignoreSingleWhenExpression: false ignoreSimpleWhenEntries: false + ignoreNestingFunctions: false + nestingFunctions: + - 'also' + - 'apply' + - 'forEach' + - 'isNotNull' + - 'ifNull' + - 'let' + - 'run' + - 'use' + - 'with' LabeledExpression: active: false - ignoredLabels: "" + ignoredLabels: [] LargeClass: active: true threshold: 600 LongMethod: - active: false + active: true threshold: 60 LongParameterList: active: true - threshold: 6 + functionThreshold: 15 + constructorThreshold: 15 ignoreDefaultParameters: false + ignoreDataClasses: true + ignoreAnnotatedParameter: [] MethodOverloading: - active: true + active: false threshold: 6 + NamedArguments: + active: false + threshold: 3 + ignoreArgumentsMatchingNames: false NestedBlockDepth: active: true threshold: 4 + NestedScopeFunctions: + active: false + threshold: 1 + functions: + - 'kotlin.apply' + - 'kotlin.run' + - 'kotlin.with' + - 'kotlin.let' + - 'kotlin.also' + ReplaceSafeCallChainWithRun: + active: false StringLiteralDuplication: - active: true + active: false + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] threshold: 3 ignoreAnnotation: true excludeStringsWithLessThan5Characters: true ignoreStringsRegex: '$^' TooManyFunctions: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - thresholdInFiles: 30 - thresholdInClasses: 30 - thresholdInInterfaces: 30 - thresholdInObjects: 15 - thresholdInEnums: 15 + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + thresholdInFiles: 11 + thresholdInClasses: 11 + thresholdInInterfaces: 11 + thresholdInObjects: 11 + thresholdInEnums: 11 ignoreDeprecated: false ignorePrivate: false ignoreOverridden: false +coroutines: + active: true + GlobalCoroutineUsage: + active: false + InjectDispatcher: + active: true + dispatcherNames: + - 'IO' + - 'Default' + - 'Unconfined' + RedundantSuspendModifier: + active: true + SleepInsteadOfDelay: + active: true + SuspendFunWithCoroutineScopeReceiver: + active: false + SuspendFunWithFlowReturnType: + active: true + empty-blocks: active: true EmptyCatchBlock: active: true - allowedExceptionNameRegex: "^(_|(ignore|expected).*)" + allowedExceptionNameRegex: '_|(ignore|expected).*' EmptyClassBlock: active: true EmptyDefaultConstructor: @@ -103,6 +222,8 @@ empty-blocks: active: true EmptySecondaryConstructor: active: true + EmptyTryBlock: + active: true EmptyWhenBlock: active: true EmptyWhileBlock: @@ -112,222 +233,149 @@ exceptions: active: true ExceptionRaisedInUnexpectedLocation: active: true - methodNames: 'toString,hashCode,equals,finalize' + methodNames: + - 'equals' + - 'finalize' + - 'hashCode' + - 'toString' InstanceOfCheckForException: active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] NotImplementedDeclaration: active: false - PrintStackTrace: + ObjectExtendsThrowable: active: false + PrintStackTrace: + active: true RethrowCaughtException: - active: false + active: true ReturnFromFinally: active: true + ignoreLabeled: false SwallowedException: active: false - ignoredExceptionTypes: 'InterruptedException,NumberFormatException,ParseException,MalformedURLException' + ignoredExceptionTypes: + - 'InterruptedException' + - 'MalformedURLException' + - 'NumberFormatException' + - 'ParseException' + allowedExceptionNameRegex: '_|(ignore|expected).*' ThrowingExceptionFromFinally: active: true ThrowingExceptionInMain: - active: true + active: false ThrowingExceptionsWithoutMessageOrCause: active: true - exceptions: 'IllegalArgumentException,IllegalStateException,IOException' + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + exceptions: + - 'ArrayIndexOutOfBoundsException' + - 'Exception' + - 'IllegalArgumentException' + - 'IllegalMonitorStateException' + - 'IllegalStateException' + - 'IndexOutOfBoundsException' + - 'NullPointerException' + - 'RuntimeException' + - 'Throwable' ThrowingNewInstanceOfSameException: active: true TooGenericExceptionCaught: active: false - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] exceptionNames: - - ArrayIndexOutOfBoundsException - - Error - - Exception - - IllegalMonitorStateException - - NullPointerException - - IndexOutOfBoundsException - - RuntimeException - - Throwable - allowedExceptionNameRegex: "^(_|(ignore|expected).*)" + - 'ArrayIndexOutOfBoundsException' + - 'Error' + - 'Exception' + - 'IllegalMonitorStateException' + - 'IndexOutOfBoundsException' + - 'NullPointerException' + - 'RuntimeException' + - 'Throwable' + allowedExceptionNameRegex: '_|(ignore|expected).*' TooGenericExceptionThrown: - active: true + active: false exceptionNames: - - Error - - Exception - - Throwable - - RuntimeException - -formatting: - active: true - android: true - ChainWrapping: - active: true - autoCorrect: true - CommentSpacing: - active: true - autoCorrect: true - Filename: - active: true - FinalNewline: - active: true - autoCorrect: true - ImportOrdering: - active: true - Indentation: - active: true - indentSize: 4 - continuationIndentSize: 4 - MaximumLineLength: - active: true - maxLineLength: 120 - ModifierOrdering: - active: true - autoCorrect: true - MultiLineIfElse: - active: true - autoCorrect: true - NoBlankLineBeforeRbrace: - active: true - autoCorrect: true - NoConsecutiveBlankLines: - active: true - autoCorrect: true - NoEmptyClassBody: - active: true - autoCorrect: true - NoLineBreakAfterElse: - active: true - autoCorrect: true - NoLineBreakBeforeAssignment: - active: true - autoCorrect: true - NoMultipleSpaces: - active: true - autoCorrect: true - NoSemicolons: - active: true - autoCorrect: true - NoTrailingSpaces: - active: true - autoCorrect: true - NoUnitReturn: - active: true - autoCorrect: true - NoUnusedImports: - active: true - autoCorrect: true - NoWildcardImports: - active: true - autoCorrect: true - PackageName: - active: true - autoCorrect: true - ParameterListWrapping: - active: true - autoCorrect: true - indentSize: 4 - SpacingAroundColon: - active: true - autoCorrect: true - SpacingAroundComma: - active: true - autoCorrect: true - SpacingAroundCurly: - active: true - autoCorrect: true - SpacingAroundDot: - active: true - autoCorrect: true - SpacingAroundKeyword: - active: true - autoCorrect: true - SpacingAroundOperators: - active: true - autoCorrect: true - SpacingAroundParens: - active: true - autoCorrect: true - SpacingAroundRangeOperator: - active: true - autoCorrect: true - StringTemplate: - active: true - autoCorrect: true + - 'Error' + - 'Exception' + - 'RuntimeException' + - 'Throwable' naming: active: true + BooleanPropertyNaming: + active: false + allowedPattern: '^(is|has|are)' + ignoreOverridden: true ClassNaming: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - classPattern: '[A-Z$][a-zA-Z0-9$]*' + classPattern: '[A-Z][a-zA-Z0-9]*' ConstructorParameterNaming: active: false - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" parameterPattern: '[a-z][A-Za-z0-9]*' privateParameterPattern: '[a-z][A-Za-z0-9]*' excludeClassPattern: '$^' + ignoreOverridden: true EnumNaming: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - enumEntryPattern: '^[A-Z][_a-zA-Z0-9]*' + enumEntryPattern: '[A-Z][_a-zA-Z0-9]*' ForbiddenClassName: active: false - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - forbiddenName: '' + forbiddenName: [] FunctionMaxLength: active: false - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" maximumFunctionNameLength: 30 FunctionMinLength: active: false - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" minimumFunctionNameLength: 3 FunctionNaming: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - functionPattern: '^([a-z$][a-zA-Z$0-9]*)|(`.*`)$' + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + functionPattern: '[a-z][a-zA-Z0-9]*' excludeClassPattern: '$^' ignoreOverridden: true FunctionParameterNaming: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" parameterPattern: '[a-z][A-Za-z0-9]*' excludeClassPattern: '$^' ignoreOverridden: true InvalidPackageDeclaration: - active: false + active: true rootPackage: '' + requireRootInDeclaration: false + LambdaParameterNaming: + active: false + parameterPattern: '[a-z][A-Za-z0-9]*|_' MatchingDeclarationName: active: true + mustBeFirst: true MemberNameEqualsClassName: active: false ignoreOverridden: true + NoNameShadowing: + active: true + NonBooleanPropertyPrefixedWithIs: + active: false ObjectPropertyNaming: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" constantPattern: '[A-Za-z][_A-Za-z0-9]*' propertyPattern: '[A-Za-z][_A-Za-z0-9]*' privatePropertyPattern: '(_)?[A-Za-z][_A-Za-z0-9]*' PackageNaming: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - packagePattern: '^[a-z]+(\.[a-z][A-Za-z0-9]*)*$' + packagePattern: '[a-z]+(\.[a-z][A-Za-z0-9]*)*' TopLevelPropertyNaming: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" constantPattern: '[A-Z][_A-Z0-9]*' propertyPattern: '[A-Za-z][_A-Za-z0-9]*' privatePropertyPattern: '_?[A-Za-z][_A-Za-z0-9]*' VariableMaxLength: active: false - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" maximumVariableNameLength: 64 VariableMinLength: active: false - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" minimumVariableNameLength: 1 VariableNaming: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" variablePattern: '[a-z][A-Za-z0-9]*' privateVariablePattern: '(_)?[a-z][A-Za-z0-9]*' excludeClassPattern: '$^' @@ -337,25 +385,73 @@ performance: active: true ArrayPrimitive: active: true + CouldBeSequence: + active: false + threshold: 3 ForEachOnRange: active: true - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] SpreadOperator: + active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + UnnecessaryPartOfBinaryExpression: active: false - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" UnnecessaryTemporaryInstantiation: active: true potential-bugs: active: true - DuplicateCaseInWhenExpression: + AvoidReferentialEquality: + active: true + forbiddenTypePatterns: + - 'kotlin.String' + CastToNullableType: + active: false + Deprecation: + active: false + DontDowncastCollectionTypes: + active: false + DoubleMutabilityForCollection: active: true + mutableTypes: + - 'kotlin.collections.MutableList' + - 'kotlin.collections.MutableMap' + - 'kotlin.collections.MutableSet' + - 'java.util.ArrayList' + - 'java.util.LinkedHashSet' + - 'java.util.HashSet' + - 'java.util.LinkedHashMap' + - 'java.util.HashMap' + ElseCaseInsteadOfExhaustiveWhen: + active: false EqualsAlwaysReturnsTrueOrFalse: active: true EqualsWithHashCodeExist: active: true + ExitOutsideMain: + active: false ExplicitGarbageCollectionCall: active: true + HasPlatformType: + active: true + IgnoredReturnValue: + active: true + restrictToConfig: true + returnValueAnnotations: + - '*.CheckResult' + - '*.CheckReturnValue' + ignoreReturnValueAnnotations: + - '*.CanIgnoreReturnValue' + returnValueTypes: + - 'kotlin.sequences.Sequence' + - 'kotlinx.coroutines.flow.*Flow' + - 'java.util.stream.*Stream' + ignoreFunctionCall: [] + ImplicitDefaultLocale: + active: true + ImplicitUnitReturnType: + active: false + allowExplicitReturnType: true InvalidRange: active: true IteratorHasNextCallsNextMethod: @@ -364,21 +460,36 @@ potential-bugs: active: true LateinitUsage: active: false - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - excludeAnnotatedProperties: "" - ignoreOnClassesPattern: "" - MissingWhenCase: + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + ignoreOnClassesPattern: '' + MapGetWithNotNullAssertionOperator: + active: true + MissingPackageDeclaration: + active: false + excludes: ['**/*.kts'] + NullCheckOnMutableProperty: active: false - RedundantElseInWhen: + NullableToStringCall: active: false UnconditionalJumpStatementInLoop: + active: false + UnnecessaryNotNullCheck: + active: false + UnnecessaryNotNullOperator: + active: true + UnnecessarySafeCall: + active: true + UnreachableCatchBlock: active: true UnreachableCode: active: true UnsafeCallOnNullableType: - active: false + active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] UnsafeCast: active: true + UnusedUnaryOperator: + active: true UselessPostfixExpression: active: true WrongEqualsTypeParameter: @@ -386,135 +497,228 @@ potential-bugs: style: active: true + AlsoCouldBeApply: + active: false + CanBeNonNullable: + active: false + CascadingCallWrapping: + active: false + includeElvis: true + ClassOrdering: + active: false CollapsibleIfStatements: - active: true + active: false DataClassContainsFunctions: active: false - conversionFunctionPrefix: 'to' + conversionFunctionPrefix: + - 'to' DataClassShouldBeImmutable: active: false + DestructuringDeclarationWithTooManyEntries: + active: true + maxDestructuringEntries: 3 EqualsNullCall: active: true EqualsOnSignatureLine: - active: true + active: false + ExplicitCollectionElementAccessMethod: + active: false ExplicitItLambdaParameter: active: true ExpressionBodySyntax: - active: true + active: false includeLineWrapping: false ForbiddenComment: active: true - values: 'FIXME:,STOPSHIP:' + values: + - 'FIXME:' + - 'STOPSHIP:' + - 'TODO:' + allowedPatterns: '' + customMessage: '' ForbiddenImport: active: false - imports: '' + imports: [] + forbiddenPatterns: '' + ForbiddenMethodCall: + active: false + methods: + - reason: 'print does not allow you to configure the output stream. Use a logger instead.' + value: 'kotlin.io.print' + - reason: 'println does not allow you to configure the output stream. Use a logger instead.' + value: 'kotlin.io.println' + ForbiddenSuppress: + active: false + rules: [] ForbiddenVoid: active: true ignoreOverridden: false + ignoreUsageInGenerics: false FunctionOnlyReturningConstant: active: true ignoreOverridableFunction: true - excludedFunctions: 'describeContents' - LibraryCodeMustSpecifyReturnType: - active: true + ignoreActualFunction: true + excludedFunctions: [] LoopWithTooManyJumpStatements: active: true maxJumpCount: 1 MagicNumber: active: false - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - ignoreNumbers: '-1,0,1,2' + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**', '**/*.kts'] + ignoreNumbers: + - '-1' + - '0' + - '1' + - '2' ignoreHashCodeFunction: true - ignorePropertyDeclaration: true + ignorePropertyDeclaration: false + ignoreLocalVariableDeclaration: false ignoreConstantDeclaration: true ignoreCompanionObjectPropertyDeclaration: true ignoreAnnotation: false ignoreNamedArgument: true ignoreEnums: false ignoreRanges: false - ignoreLocalVariableDeclaration: true + ignoreExtensionFunctions: true MandatoryBracesIfStatements: - active: true - MaxLineLength: active: false - maxLineLength: 120 + MandatoryBracesLoops: + active: false + MaxChainedCallsOnSameLine: + active: false + maxChainedCalls: 5 + MaxLineLength: + active: true + maxLineLength: 250 excludePackageStatements: true excludeImportStatements: true excludeCommentStatements: false + excludeRawStrings: true MayBeConst: active: true ModifierOrder: active: true + MultilineLambdaItParameter: + active: false + MultilineRawStringIndentation: + active: false + indentSize: 4 NestedClassesVisibility: active: true NewLineAtEndOfFile: active: false NoTabs: + active: false + NullableBooleanCheck: + active: false + ObjectLiteralToLambda: active: true OptionalAbstractKeyword: active: true OptionalUnit: - active: true + active: false OptionalWhenBraces: active: false PreferToOverPairSyntax: - active: true + active: false ProtectedMemberInFinalClass: active: true - RedundantVisibilityModifierRule: + RedundantExplicitType: + active: false + RedundantHigherOrderMapUsage: active: true - ReturnCount: + RedundantVisibilityModifierRule: active: false - max: 2 - excludedFunctions: "equals" + ReturnCount: + active: true + max: 4 + excludedFunctions: + - 'equals' excludeLabeled: false excludeReturnFromLambda: true + excludeGuardClauses: false SafeCast: active: true SerialVersionUIDInSerializableClass: active: true SpacingBetweenPackageAndImports: - active: true + active: false ThrowsCount: active: true max: 2 + excludeGuardClauses: false TrailingWhitespace: - active: true + active: false + TrimMultilineRawString: + active: false UnderscoresInNumericLiterals: active: false - acceptableDecimalLength: 5 + acceptableLength: 4 + allowNonStandardGrouping: false UnnecessaryAbstractClass: + active: true + UnnecessaryAnnotationUseSiteTarget: active: false - excludeAnnotatedClasses: "dagger.Module" UnnecessaryApply: + active: true + UnnecessaryBackticks: active: false + UnnecessaryFilter: + active: true UnnecessaryInheritance: active: true + UnnecessaryInnerClass: + active: false UnnecessaryLet: - active: true + active: false UnnecessaryParentheses: active: false + allowForUnclearPrecedence: false UntilInsteadOfRangeTo: - active: true + active: false UnusedImports: - active: true + active: false UnusedPrivateClass: active: true UnusedPrivateMember: - active: false + active: true allowedNames: '(_|ignored|expected|serialVersionUID)' + UseAnyOrNoneInsteadOfFind: + active: true + UseArrayLiteralsInAnnotations: + active: true + UseCheckNotNull: + active: true + UseCheckOrError: + active: true UseDataClass: active: false - excludeAnnotatedClasses: "" + allowVars: false + UseEmptyCounterpart: + active: false + UseIfEmptyOrIfBlank: + active: false + UseIfInsteadOfWhen: + active: false + UseIsNullOrEmpty: + active: true + UseOrEmpty: + active: true UseRequire: + active: true + UseRequireNotNull: + active: true + UseSumOfInsteadOfFlatMapSize: active: false UselessCallOnNotNull: - active: false + active: true UtilityClassWithPublicConstructor: active: true VarCouldBeVal: active: true + ignoreLateinitVar: false WildcardImport: - active: false - excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" - excludeImports: 'java.util.*,kotlinx.android.synthetic.*' \ No newline at end of file + active: true + excludeImports: + - 'java.util.*' + - 'com.androidstudy.daraja.callback.*' diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 67f97e4..c431eed 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip diff --git a/settings.gradle.kts b/settings.gradle.kts index 1450b11..60efa84 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -5,19 +5,10 @@ pluginManagement { } plugins { - id("com.android.application") version "7.2.1" - id("org.jetbrains.kotlin.android") version "1.7.0" - id("org.jetbrains.kotlin.android.extensions") version "1.7.0" - id("com.android.library") version "7.2.1" - id("com.google.firebase.crashlytics") version "2.1.0" - } - - resolutionStrategy { - eachPlugin { - when (requested.id.id) { - "com.google.firebase.crashlytics" -> useModule("com.google.firebase:firebase-crashlytics-gradle:2.1.0") - } - } + id("com.android.application") version "7.4.1" + id("org.jetbrains.kotlin.android") version "1.8.0" + id("com.android.library") version "7.4.1" + id("com.google.firebase.crashlytics") version "2.5.2" } }