diff --git a/README.md b/README.md index 35ec7bb..816c62a 100644 --- a/README.md +++ b/README.md @@ -3,30 +3,51 @@ ## Status [![Build Status](https://app.bitrise.io/app/6a0a30b884ce6131/status.svg?token=q0pKDUFK3Qfa6sXfy66vog&branch=master)](https://app.bitrise.io/app/6a0a30b884ce6131) -![LINE](https://img.shields.io/badge/line--coverage-98%25-brightgreen.svg) -![BRANCH](https://img.shields.io/badge/branch--coverage-82%25-brightgreen.svg) -![COMPLEXITY](https://img.shields.io/badge/complexity-1.64-brightgreen.svg) [![Github](https://img.shields.io/github/release/hmrc/help-to-save-kalculator.svg)](https://gitHub.com/hmrc/help-to-save-kalculator/releases/) ![swift-pm](https://img.shields.io/badge/SwiftPM-Compatible-success.svg) -## Calculate help to save bonus -## For new users +# Contents +* [Bonus for new users](#bonus-for-new-users) +* [Bonus for existing accounts](#bonus-for-existing-accounts) +* [Accounts in first term](#accounts-in-first-term) +* [Existing accounts in final term](#existing-accounts-in-final-term) +* [Usage](#usage) +* [Release process](#release-process) +* [License](#license) + +## Bonus for new users +#### Android ```kotlin Calculator.run(regularPayment = 50.0) // Must be between 1 and 50) ``` -## For users with existing accounts +#### iOS +```swift +Calculator().run(regularPayment: 50.0) // Must be between 1 and 50) +``` +## Bonus for existing accounts +#### Android ```kotlin Calculator.run( - regularPayment = 50.0, // Must be between 1 and 50 - currentBalance = 100.0, - currentPeriod1Bonus = 50.0, - currentPeriod2Bonus = 0.0, - accountStartDate = DateTime() + regularPayment = 50.0, // Must be between 1 and 50 + currentBalance = 100.0, + currentPeriod1Bonus = 50.0, + currentPeriod2Bonus = 0.0, + accountStartDate = DateTime() +) +``` +#### iOS +```swift +Calculator().run( + regularPayment: 50.0, // Must be between 1 and 50 + currentBalance: 100.0, + currentPeriod1Bonus: 50.0, + currentPeriod2Bonus: 0.0, + accountStartDate: Date() ) ``` -### Response -This will returns an object of type `CalculatorResponse`. This provides headline figures that are the results at the end of the scheme. However, if a monthly breakdown is needed a cumulative breakdown is provided in `monthlyBreakdown` +### Response structure +This will return an object of type `CalculatorResponse`. This provides headline figures that are the results at the end of the scheme. However, if a monthly breakdown is needed a cumulative breakdown is provided in `monthlyBreakdown` * `monthlyPayments: Double` * `monthlyBreakdown: List` @@ -45,10 +66,14 @@ This will returns an object of type `CalculatorResponse`. This provides headlin * `endOfPeriod2Savings: Double` * `endOfPeriod2Total: Double` -## For existing accounts in first term +## Accounts in first term +#### Android ```kotlin FirstBonusTermCalculator.runFirstBonusCalculator(input) ``` +```swift +FirstBonusTermCalculator().runFirstBonusCalculator(input) +``` Where `input` is of the type `FirstBonusInput` with the following parameters: ``` regularPayment: Double, // 25.0 @@ -70,7 +95,7 @@ This will returns an object of type `FirstBonusCalculatorResponse`. * `projectedAdditionalSavingsFinalBonusPeriod: Double` * `projectedFinalBonus: Double` -## For existing accounts in final term +## Existing accounts in final term ```kotlin FinalBonusTermCalculator.runFinalBonusCalculator(input) ``` @@ -102,48 +127,20 @@ val isAboveMinimumRegularPayments = RegularPaymentValidators.isAboveMinimumRegul val isBelowMaximumRegularPayments = RegularPaymentValidators.isBelowMaximumRegularPayments(50.0) // true ``` -## Installation +## Usage ### iOS #### Swift Package Manager -- From version `0.5.0` onwards, the use of `Swift Package Manager` is required. -- Note: Because this operates as a closed source, binary dependency, Swift PM will only work with tagged releases and not branches. +> Because this operates as a closed source, binary dependency, Swift PM will only work with tagged releases and not branches. ```swift https://github.com/hmrc/help-to-save-kalculator ``` -#### Carthage -- For all versions below `0.5.0`, the use of `Carthage` is required. -- Each release tag includes a Carthage binary dependency specification. To use the Carthage binary: -* In the same directory as your Cartfile, add a directory. -```shell script -$ mkdir Carthage-Binaries -``` -* Add a JSON file that holds your Carthage binary specifications. -```shell script -$ touch Carthage-Binaries/HelpToSaveKalculator.json -``` -* Point to the latest release in your JSON file. -```json - { - "0.3.7": "https://github.com/hmrc/help-to-save-kalculator/releases/download/0.3.7/HelpToSaveKalculator.framework.zip" - } -``` -* List the dependency in your Cartfile -```shell script - ... - binary "Carthage-Binaries/HelpToSaveKalculator.json" == 0.3.7 - ... -``` -* Update your Carthage dependencies as per your requirements. - -#### Simulator Architectures: -* Most Carthage users will include a Carthage [copy-frameworks](https://www.raywenderlich.com/416-carthage-tutorial-getting-started) build step that removes unwanted architectures for -distribution builds. -* If you don't use Carthage and just download and link the framework in your project, it'll be necessary to strip unwanted architectures in a build step. -You may want to implement something like [this](http://ikennd.ac/blog/2015/02/stripping-unwanted-architectures-from-dynamic-libraries-in-xcode/). +#### Simulator Architectures: +* If the framework is downloaded and linked in the project, it'll be necessary to strip unwanted architectures in a build step. + * For example, you may want to implement something like [this](http://ikennd.ac/blog/2015/02/stripping-unwanted-architectures-from-dynamic-libraries-in-xcode/). -### Android or JVM +### Android & JVM Add the Github Package repository to your top-level `build.gradle`, along with a Github username and access token (no permissions required). @@ -167,32 +164,28 @@ dependencies { } ``` -## Development - -To run unit tests and checks: - -`./gradlew check` - -To update the README badges: +## Release process -`./gradlew cleanBuildTestCoverage` - -### Release process - -The CI tool has been set up to trigger a build and publish to GitHub packages when a tag is created on a build. - -Recommended flow: -- Raise PR -- Approved PR -- Merge -- Wait for Bitrise to build and test -- Tag for release -- Apps update to new version +```shell +bundle exec fastlane tag_release +``` -You need to: -* Have a valid Bitrise access token saved in your path under the variable name `BITRISE_TOKEN`. See [Bitrise docs](https://devcenter.bitrise.io/api/authentication). +### Required +* A valid Bitrise access token saved in your path under the variable name `BITRISE_TOKEN`. See [Bitrise docs](https://devcenter.bitrise.io/api/authentication). * Two environment variables, `HTS_KALC_APP_SLUG` & `HTS_KALC_RELEASE_WORKFLOW_ID` will also need to be included in your bash/ZSH profile. Speak with [Chris](https://github.com/chrisob55) to obtain these values. +### Steps executed +* Ensure git status is clean +* Ensure `main` branch +* Through the interactive shell, select the tag version using semantic versioning. +* Locally executes `build_xcframework.sh`: + * Creates an XCFramework + * Computes and updates the checksum in the Swift Package declaration. +* Stamps the changelog +* Commit and push the updated `Package.swift` and `CHANGELOG.md` +* Upload release artifacts to tagged Github release +* Executes `release.sh` to start the CI pipeline on CI. + ### License This code is open source software licensed under the [Apache 2.0 License]("http://www.apache.org/licenses/LICENSE-2.0.html"). diff --git a/build.gradle.kts b/build.gradle.kts index 725db80..e58496a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,9 +1,5 @@ import java.text.SimpleDateFormat -import java.util.Calendar import java.util.Date -import java.util.Properties -import org.gradle.api.tasks.GradleBuild -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile buildscript{ repositories { @@ -20,10 +16,6 @@ buildscript{ } } - -/*********************************************************************************************************************** - * Project Gradle Config - ***********************************************************************************************************************/ apply(plugin = "uk.gov.hmrc.spotless") group = "uk.gov.hmrc" @@ -32,12 +24,11 @@ version = System.getenv("BITRISE_GIT_TAG") ?: ("SNAPSHOT-" + getDate()) plugins { `maven-publish` - kotlin("multiplatform").version("1.4.10") - jacoco + kotlin("multiplatform").version("1.6.0") java - id("com.github.dawnwords.jacoco.badge").version("0.1.0") - id("io.gitlab.arturbosch.detekt").version("1.1.1") + id("io.gitlab.arturbosch.detekt").version("1.6.0") id("com.chromaticnoise.multiplatform-swiftpackage").version("2.0.3") + id("org.jetbrains.kotlinx.kover") version "0.5.0" } repositories { @@ -48,33 +39,10 @@ repositories { } } -/*********************************************************************************************************************** - * Declarations - ***********************************************************************************************************************/ - val artifactId = "help-to-save-kalculator" val frameworkName = "HelpToSaveKalculator" -val licenseString = """/* - * Copyright ${getYear()} HM Revenue & Customs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -""" - -/*********************************************************************************************************************** - * Kotlin Configuration - ***********************************************************************************************************************/ +// Configure source sets kotlin { jvm() @@ -92,7 +60,7 @@ kotlin { } sourceSets.all { - languageSettings.useExperimentalAnnotation("kotlin.Experimental") + languageSettings.optIn("kotlin.Experimental") } sourceSets { @@ -107,6 +75,8 @@ kotlin { dependencies { implementation(kotlin("test-common")) implementation(kotlin("test-annotations-common")) + implementation("io.kotlintest:kotlintest-runner-junit5:3.4.2") + runtimeOnly("org.junit.jupiter:junit-jupiter-engine:5.7.1") } } @@ -119,7 +89,8 @@ kotlin { val jvmTest by getting { dependencies { implementation(kotlin("test")) - implementation(kotlin("test-junit")) + implementation(kotlin("test-junit5")) + implementation("org.junit.jupiter:junit-jupiter-params:5.7.1") } } @@ -129,8 +100,7 @@ kotlin { } } - val iosTest by getting { - } + val iosTest by getting {} val iosArm32Main by sourceSets.getting val iosArm64Main by sourceSets.getting @@ -147,10 +117,7 @@ kotlin { } } -/*********************************************************************************************************************** - * Swift Package Manager Configuration - ***********************************************************************************************************************/ - +// Configure Swift Package Manager multiplatformSwiftPackage { swiftToolsVersion("5.3") targetPlatforms { @@ -159,34 +126,7 @@ multiplatformSwiftPackage { outputDirectory(File(projectDir, "build/xcframework")) } -/*********************************************************************************************************************** - * Other Task Configuration - ***********************************************************************************************************************/ - -configurations { - compileClasspath -} - -jacocoBadgeGenSetting { - - jacocoReportPath = "$buildDir/reports/jacoco/commonUnitTestCoverage/commonUnitTestCoverage.xml" -} - -jacoco { - toolVersion = "0.8.4" -} - -detekt { - input = files("src/commonMain/kotlin") - config = files("detekt-config.yml") - reports { - html { - enabled = true - destination = file("build/reports/detekt/index.html") - } - } -} - +// Configure GitHub Packages publishing publishing { publications { create("mavenJava") { @@ -207,29 +147,39 @@ publishing { } } -tasks.jacocoTestCoverageVerification { - group = project.name +configurations { + compileClasspath +} - violationRules { - rule { - limit { - minimum = "0.87".toBigDecimal() - } +detekt { + input = files("src/commonMain/kotlin") + config = files("detekt-config.yml") + reports { + html { + enabled = true + destination = file("build/reports/detekt/index.html") } } - val excludes = listOf("**/*Test*.*") - val coverageSourceDirs = listOf("src/commonMain/kotlin") - sourceDirectories.setFrom(files(coverageSourceDirs)) - classDirectories.setFrom(fileTree("${project.buildDir}/classes/kotlin/jvm/").exclude(excludes)) - executionData.setFrom(files("${project.buildDir}/jacoco/jvmTest.exec")) } +tasks.koverVerify { + rule { + name = "Coverage rate" + bound { + minValue = 95 + valueType = kotlinx.kover.api.VerificationValueType.COVERED_LINES_PERCENTAGE + } + } +} -/*********************************************************************************************************************** - * Custom Functions - **********************************************************************************************************************/ -fun getYear(): String { - return Calendar.getInstance().get(Calendar.YEAR).toString() +tasks.named("jvmTest") { + useJUnitPlatform() + testLogging { + showExceptions = true + showStandardStreams = true + events = setOf(org.gradle.api.tasks.testing.logging.TestLogEvent.FAILED, org.gradle.api.tasks.testing.logging.TestLogEvent.PASSED) + exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL + } } fun getDate(): String { @@ -237,38 +187,3 @@ fun getDate(): String { val format = "yyyyMMddHHmm" return SimpleDateFormat(format).format(date).toString() } - - -/*********************************************************************************************************************** - * Custom Tasks - ***********************************************************************************************************************/ - -tasks.register("commonUnitTestCoverage") { - group = project.name - description = "Generate Jacoco coverage reports on the common module build." - - this.dependsOn("allTests") - val excludes = listOf("**/*Test*.*") - val coverageSourceDirs = listOf("src/commonMain/kotlin") - executionData(files("${project.buildDir}/jacoco/jvmTest.exec")) - - reports { - xml.isEnabled = true - html.isEnabled = true - sourceDirectories.setFrom(files(coverageSourceDirs)) - classDirectories.setFrom(fileTree("${project.buildDir}/classes/kotlin/jvm/").exclude(excludes)) - } -} - -tasks.register("cleanBuildTestCoverage") { - group = project.name - - tasks = listOf( - "clean", - "cleanAllTests", - "build", - "commonUnitTestCoverage", - "generateJacocoBadge", - "jacocoTestCoverageVerification" - ) -} diff --git a/detekt-config.yml b/detekt-config.yml index 1c347dd..aed04b9 100644 --- a/detekt-config.yml +++ b/detekt-config.yml @@ -1,14 +1,21 @@ build: maxIssues: 0 + excludeCorrectable: false weights: # complexity: 2 # LongParameterList: 1 # style: 1 # comments: 1 +config: + validation: true + # when writing own rules with new properties, exclude the property path e.g.: "my_rule_set,.*>.*>[my_property]" + excludes: "" + processors: active: true exclude: + - 'DetektProgressListener' # - 'FunctionCountProcessor' # - 'PropertyCountProcessor' # - 'ClassCountProcessor' @@ -18,11 +25,11 @@ processors: console-reports: active: true exclude: - # - 'ProjectStatisticsReport' - # - 'ComplexityReport' - # - 'NotificationReport' - # - 'FindingsReport' - # - 'BuildFailureReport' + - 'ProjectStatisticsReport' + - 'ComplexityReport' + - 'NotificationReport' + # - 'FindingsReport' + - 'FileBasedFindingsReport' comments: active: true @@ -42,6 +49,8 @@ comments: searchInInnerInterface: true UndocumentedPublicFunction: active: false + UndocumentedPublicProperty: + active: false complexity: active: true @@ -54,9 +63,11 @@ complexity: includeStaticDeclarations: false ComplexMethod: active: true - threshold: 10 + threshold: 15 ignoreSingleWhenExpression: false ignoreSimpleWhenEntries: false + ignoreNestingFunctions: false + nestingFunctions: run,let,apply,with,also,use,forEach,isNotNull,ifNull LabeledExpression: active: false ignoredLabels: "" @@ -95,6 +106,13 @@ complexity: ignorePrivate: false ignoreOverridden: false +coroutines: + active: true + GlobalCoroutineUsage: + active: false + RedundantSuspendModifier: + active: false + empty-blocks: active: true EmptyCatchBlock: @@ -114,7 +132,7 @@ empty-blocks: active: true EmptyFunctionBlock: active: true - ignoreOverriddenFunctions: false + ignoreOverridden: false EmptyIfBlock: active: true EmptyInitBlock: @@ -123,6 +141,8 @@ empty-blocks: active: true EmptySecondaryConstructor: active: true + EmptyTryBlock: + active: true EmptyWhenBlock: active: true EmptyWhileBlock: @@ -144,9 +164,11 @@ exceptions: active: false ReturnFromFinally: active: false + ignoreLabeled: false SwallowedException: active: false ignoredExceptionTypes: 'InterruptedException,NumberFormatException,ParseException,MalformedURLException' + allowedExceptionNameRegex: "^(_|(ignore|expected).*)" ThrowingExceptionFromFinally: active: false ThrowingExceptionInMain: @@ -183,21 +205,28 @@ formatting: autoCorrect: true AnnotationOnSeparateLine: active: false + autoCorrect: true ChainWrapping: active: true autoCorrect: true CommentSpacing: active: true autoCorrect: true + EnumEntryNameCase: + active: false + autoCorrect: true Filename: active: true FinalNewline: active: true autoCorrect: true + insertFinalNewLine: true ImportOrdering: active: false + autoCorrect: true Indentation: active: false + autoCorrect: true indentSize: 4 continuationIndentSize: 4 MaximumLineLength: @@ -218,8 +247,9 @@ formatting: NoEmptyClassBody: active: true autoCorrect: true - NoItParamInMultilineLambda: + NoEmptyFirstLineInMethodBlock: active: false + autoCorrect: true NoLineBreakAfterElse: active: true autoCorrect: true @@ -243,14 +273,13 @@ formatting: autoCorrect: true NoWildcardImports: active: true - autoCorrect: true PackageName: active: true autoCorrect: true ParameterListWrapping: active: true autoCorrect: true -# indentSize: 4 + indentSize: 4 SpacingAroundColon: active: true autoCorrect: true @@ -275,9 +304,6 @@ formatting: SpacingAroundRangeOperator: active: true autoCorrect: true - SpacingAroundUnaryOperators: - active: true - autoCorrect: true StringTemplate: active: true autoCorrect: true @@ -294,6 +320,7 @@ naming: 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" @@ -321,15 +348,16 @@ naming: excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" parameterPattern: '[a-z][A-Za-z0-9]*' excludeClassPattern: '$^' - ignoreOverriddenFunctions: true + ignoreOverridden: true InvalidPackageDeclaration: active: false rootPackage: '' MatchingDeclarationName: active: true + mustBeFirst: true MemberNameEqualsClassName: - active: false - ignoreOverriddenFunction: true + active: true + ignoreOverridden: true ObjectPropertyNaming: active: true excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" @@ -365,7 +393,7 @@ naming: performance: active: true ArrayPrimitive: - active: false + active: true ForEachOnRange: active: true excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" @@ -377,41 +405,49 @@ performance: potential-bugs: active: true + Deprecation: + active: false DuplicateCaseInWhenExpression: active: true EqualsAlwaysReturnsTrueOrFalse: - active: false + active: true EqualsWithHashCodeExist: active: true ExplicitGarbageCollectionCall: active: true - InvalidRange: + HasPlatformType: active: false - IteratorHasNextCallsNextMethod: + ImplicitDefaultLocale: active: false + InvalidRange: + active: true + IteratorHasNextCallsNextMethod: + active: true IteratorNotThrowingNoSuchElementException: - active: false + active: true LateinitUsage: active: false excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" excludeAnnotatedProperties: "" ignoreOnClassesPattern: "" - MissingWhenCase: + MapGetWithNotNullAssertionOperator: active: false + MissingWhenCase: + active: true RedundantElseInWhen: - active: false + active: true UnconditionalJumpStatementInLoop: active: false UnreachableCode: active: true UnsafeCallOnNullableType: - active: false + active: true UnsafeCast: active: false UselessPostfixExpression: active: false WrongEqualsTypeParameter: - active: false + active: true style: active: true @@ -423,9 +459,11 @@ style: DataClassShouldBeImmutable: active: false EqualsNullCall: - active: false + active: true EqualsOnSignatureLine: active: false + ExplicitCollectionElementAccessMethod: + active: false ExplicitItLambdaParameter: active: false ExpressionBodySyntax: @@ -434,27 +472,38 @@ style: ForbiddenComment: active: true values: 'TODO:,FIXME:,STOPSHIP:' + allowedPatterns: "" ForbiddenImport: active: false imports: '' + forbiddenPatterns: "" + ForbiddenMethodCall: + active: false + methods: '' + ForbiddenPublicDataClass: + active: false + ignorePackages: '*.internal,*.internal.*' ForbiddenVoid: active: false ignoreOverridden: false + ignoreUsageInGenerics: false FunctionOnlyReturningConstant: - active: false + active: true ignoreOverridableFunction: true excludedFunctions: 'describeContents' + excludeAnnotatedFunction: "dagger.Provides" LibraryCodeMustSpecifyReturnType: - active: false + active: true LoopWithTooManyJumpStatements: - active: false + active: true maxJumpCount: 1 MagicNumber: - active: false + active: true excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt" ignoreNumbers: '-1,0,1,2' ignoreHashCodeFunction: true ignorePropertyDeclaration: false + ignoreLocalVariableDeclaration: false ignoreConstantDeclaration: true ignoreCompanionObjectPropertyDeclaration: true ignoreAnnotation: false @@ -470,7 +519,7 @@ style: excludeImportStatements: true excludeCommentStatements: false MayBeConst: - active: false + active: true ModifierOrder: active: true NestedClassesVisibility: @@ -488,6 +537,8 @@ style: PreferToOverPairSyntax: active: false ProtectedMemberInFinalClass: + active: true + RedundantExplicitType: active: false RedundantVisibilityModifierRule: active: false @@ -497,6 +548,7 @@ style: excludedFunctions: "equals" excludeLabeled: false excludeReturnFromLambda: true + excludeGuardClauses: false SafeCast: active: true SerialVersionUIDInSerializableClass: @@ -504,7 +556,7 @@ style: SpacingBetweenPackageAndImports: active: false ThrowsCount: - active: false + active: true max: 2 TrailingWhitespace: active: false @@ -512,12 +564,14 @@ style: active: false acceptableDecimalLength: 5 UnnecessaryAbstractClass: - active: false + active: true excludeAnnotatedClasses: "dagger.Module" + UnnecessaryAnnotationUseSiteTarget: + active: false UnnecessaryApply: active: false UnnecessaryInheritance: - active: false + active: true UnnecessaryLet: active: false UnnecessaryParentheses: @@ -527,21 +581,26 @@ style: UnusedImports: active: false UnusedPrivateClass: - active: false + active: true UnusedPrivateMember: active: false allowedNames: "(_|ignored|expected|serialVersionUID)" + UseArrayLiteralsInAnnotations: + active: false UseCheckOrError: active: false UseDataClass: active: false excludeAnnotatedClasses: "" + allowVars: false + UseIfInsteadOfWhen: + active: false UseRequire: active: false UselessCallOnNotNull: - active: false + active: true UtilityClassWithPublicConstructor: - active: false + active: true VarCouldBeVal: active: false WildcardImport: diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..d379ab2 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,4 @@ +kotlin.code.style=official +warning-mode=all +org.gradle.warning.mode=all +org.gradle.jvmargs=-Xmx2048m \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 87b738c..e708b1c 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 4d9ca16..41dfb87 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/commonMain/kotlin/uk/gov/hmrc/.keep b/src/commonMain/kotlin/uk/gov/hmrc/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/Calculator.kt b/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/Calculator.kt index 58af41a..6f855f9 100644 --- a/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/Calculator.kt +++ b/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/Calculator.kt @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2022 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/FinalBonusTermCalculation.kt b/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/FinalBonusTermCalculation.kt index ed92430..acb4312 100644 --- a/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/FinalBonusTermCalculation.kt +++ b/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/FinalBonusTermCalculation.kt @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2022 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -58,7 +58,7 @@ internal class FinalBonusTermCalculation { input: FinalBonusInput, monthsLeftInScheme: Int ): FinalBonusStatus { - val highestPossibleBalance = input.currentBalance + input.canPayInThisMonth + (monthsLeftInScheme * 50) + val highestPossibleBalance = input.currentBalance + input.canPayInThisMonth + (monthsLeftInScheme * FIFTY) return if (input.secondTermBonusEstimate > 0.0) FinalBonusStatus.EARNED else { if (highestPossibleBalance > input.balanceMustBeMoreThanForBonus) FinalBonusStatus.POSSIBLE_TO_EARN else FinalBonusStatus.CANNOT_EARN @@ -70,4 +70,8 @@ internal class FinalBonusTermCalculation { val secondTermEndDate = input.secondTermEndDate.convertToDateTime() return thisMonthEndDate.monthsSince(secondTermEndDate) } + + companion object { + private const val FIFTY = 50 + } } diff --git a/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/FinalBonusTermCalculator.kt b/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/FinalBonusTermCalculator.kt index 089e8e9..d8db0e2 100644 --- a/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/FinalBonusTermCalculator.kt +++ b/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/FinalBonusTermCalculator.kt @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2022 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/FirstBonusTermCalculation.kt b/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/FirstBonusTermCalculation.kt index 20f3d12..8cccc95 100644 --- a/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/FirstBonusTermCalculation.kt +++ b/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/FirstBonusTermCalculation.kt @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2022 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -57,7 +57,7 @@ internal class FirstBonusTermCalculation { fun calculateProjectedFirstBonus(highestBalanceFirstBonusPeriod: Double) = highestBalanceFirstBonusPeriod / 2 - fun calculateProjectedAdditionalSavingsFinalBonusPeriod(input: FirstBonusInput) = input.regularPayment * 24 + fun calculateProjectedAdditionalSavingsFinalBonusPeriod(input: FirstBonusInput) = input.regularPayment * TWENTY_FOUR fun calculateProjectedFinalBonus( highestBalanceFinalBonusPeriod: Double, @@ -74,4 +74,8 @@ internal class FirstBonusTermCalculation { val monthsLeftInFirstTerm = thisMonthEndDate.monthsSince(firstTermEndDate) return Pair(monthsLeftInScheme, monthsLeftInFirstTerm) } + + companion object { + private const val TWENTY_FOUR = 24 + } } diff --git a/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/FirstBonusTermCalculator.kt b/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/FirstBonusTermCalculator.kt index eb07f66..a759a34 100644 --- a/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/FirstBonusTermCalculator.kt +++ b/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/FirstBonusTermCalculator.kt @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2022 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/config/HtSSchemeConfig.kt b/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/config/HtSSchemeConfig.kt index c1cddec..c376b3f 100644 --- a/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/config/HtSSchemeConfig.kt +++ b/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/config/HtSSchemeConfig.kt @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2022 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,6 +15,7 @@ */ package uk.gov.hmrc.helptosavecalculator.config +@Suppress("MagicNumber") open class HtSSchemeConfig { val endOfSecondBonusPeriod: Int = 48 val startOfSecondBonusPeriod: Int = 25 diff --git a/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/exceptions/InvalidRegularPaymentException.kt b/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/exceptions/InvalidRegularPaymentException.kt index e3c851b..324f12f 100644 --- a/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/exceptions/InvalidRegularPaymentException.kt +++ b/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/exceptions/InvalidRegularPaymentException.kt @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2022 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/models/CalculatorResponse.kt b/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/models/CalculatorResponse.kt index a447ce8..a183e7a 100644 --- a/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/models/CalculatorResponse.kt +++ b/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/models/CalculatorResponse.kt @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2022 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/models/FinalBonusInput.kt b/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/models/FinalBonusInput.kt index f56fb06..81cc857 100644 --- a/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/models/FinalBonusInput.kt +++ b/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/models/FinalBonusInput.kt @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2022 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/models/FinalBonusStatus.kt b/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/models/FinalBonusStatus.kt index d429240..a0a6854 100644 --- a/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/models/FinalBonusStatus.kt +++ b/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/models/FinalBonusStatus.kt @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2022 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/models/FirstBonusInput.kt b/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/models/FirstBonusInput.kt index e9731da..acb770b 100644 --- a/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/models/FirstBonusInput.kt +++ b/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/models/FirstBonusInput.kt @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2022 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/models/YearMonthDayInput.kt b/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/models/YearMonthDayInput.kt index 18d8cda..c2cbf3f 100644 --- a/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/models/YearMonthDayInput.kt +++ b/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/models/YearMonthDayInput.kt @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2022 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/utils/DateTime+Months.kt b/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/utils/DateTime+Months.kt index 92a3535..a4bc598 100644 --- a/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/utils/DateTime+Months.kt +++ b/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/utils/DateTime+Months.kt @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2022 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/validation/RegularPaymentValidators.kt b/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/validation/RegularPaymentValidators.kt index c9ba248..d3081f7 100644 --- a/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/validation/RegularPaymentValidators.kt +++ b/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/validation/RegularPaymentValidators.kt @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2022 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,6 +15,7 @@ */ package uk.gov.hmrc.helptosavecalculator.validation +@Suppress("MagicNumber") object RegularPaymentValidators { fun isValidRegularPayments(payment: Double) = diff --git a/src/commonMain/resources/.keep b/src/commonMain/resources/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/src/commonTest/kotlin/uk/gov/hmrc/.keep b/src/commonTest/kotlin/uk/gov/hmrc/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/src/commonTest/kotlin/uk/gov/hmrc/CalculatorTest.kt b/src/commonTest/kotlin/uk/gov/hmrc/CalculatorTest.kt index e03c21e..2889fa7 100644 --- a/src/commonTest/kotlin/uk/gov/hmrc/CalculatorTest.kt +++ b/src/commonTest/kotlin/uk/gov/hmrc/CalculatorTest.kt @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2022 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/commonTest/kotlin/uk/gov/hmrc/FinalBonusTermCalculationTest.kt b/src/commonTest/kotlin/uk/gov/hmrc/FinalBonusTermCalculationTest.kt index 89446bf..b150aae 100644 --- a/src/commonTest/kotlin/uk/gov/hmrc/FinalBonusTermCalculationTest.kt +++ b/src/commonTest/kotlin/uk/gov/hmrc/FinalBonusTermCalculationTest.kt @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2022 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/commonTest/kotlin/uk/gov/hmrc/FinalBonusTermCalculatorTest.kt b/src/commonTest/kotlin/uk/gov/hmrc/FinalBonusTermCalculatorTest.kt index 0c99370..9c83334 100644 --- a/src/commonTest/kotlin/uk/gov/hmrc/FinalBonusTermCalculatorTest.kt +++ b/src/commonTest/kotlin/uk/gov/hmrc/FinalBonusTermCalculatorTest.kt @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2022 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/commonTest/kotlin/uk/gov/hmrc/FirstBonusTermCalculationTest.kt b/src/commonTest/kotlin/uk/gov/hmrc/FirstBonusTermCalculationTest.kt index 300492c..e1e1cb7 100644 --- a/src/commonTest/kotlin/uk/gov/hmrc/FirstBonusTermCalculationTest.kt +++ b/src/commonTest/kotlin/uk/gov/hmrc/FirstBonusTermCalculationTest.kt @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2022 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/commonTest/kotlin/uk/gov/hmrc/FirstBonusTermCalculatorTest.kt b/src/commonTest/kotlin/uk/gov/hmrc/FirstBonusTermCalculatorTest.kt index 1dc47b2..fc99ad0 100644 --- a/src/commonTest/kotlin/uk/gov/hmrc/FirstBonusTermCalculatorTest.kt +++ b/src/commonTest/kotlin/uk/gov/hmrc/FirstBonusTermCalculatorTest.kt @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2022 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/commonTest/kotlin/uk/gov/hmrc/helptosavecalculator/models/CalculatorResponseTest.kt b/src/commonTest/kotlin/uk/gov/hmrc/helptosavecalculator/models/CalculatorResponseTest.kt index 15a0e66..3f2f71a 100644 --- a/src/commonTest/kotlin/uk/gov/hmrc/helptosavecalculator/models/CalculatorResponseTest.kt +++ b/src/commonTest/kotlin/uk/gov/hmrc/helptosavecalculator/models/CalculatorResponseTest.kt @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2022 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/commonTest/kotlin/uk/gov/hmrc/helptosavecalculator/utils/DateTime+MonthsTest.kt b/src/commonTest/kotlin/uk/gov/hmrc/helptosavecalculator/utils/DateTime+MonthsTest.kt index aced9d8..af9db12 100644 --- a/src/commonTest/kotlin/uk/gov/hmrc/helptosavecalculator/utils/DateTime+MonthsTest.kt +++ b/src/commonTest/kotlin/uk/gov/hmrc/helptosavecalculator/utils/DateTime+MonthsTest.kt @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2022 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/commonTest/kotlin/uk/gov/hmrc/helptosavecalculator/utils/validators/RegularPaymentValidatorsTest.kt b/src/commonTest/kotlin/uk/gov/hmrc/helptosavecalculator/utils/validators/RegularPaymentValidatorsTest.kt index a17f320..bbf9c9f 100644 --- a/src/commonTest/kotlin/uk/gov/hmrc/helptosavecalculator/utils/validators/RegularPaymentValidatorsTest.kt +++ b/src/commonTest/kotlin/uk/gov/hmrc/helptosavecalculator/utils/validators/RegularPaymentValidatorsTest.kt @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2022 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/commonTest/resources/.keep b/src/commonTest/resources/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/src/iosMain/kotlin/uk/gov/hmrc/.keep b/src/iosMain/kotlin/uk/gov/hmrc/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/src/iosMain/resources/.keep b/src/iosMain/resources/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/src/iosTest/kotlin/uk/gov/hmrc/.keep b/src/iosTest/kotlin/uk/gov/hmrc/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/src/iosTest/resources/.keep b/src/iosTest/resources/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/src/jvmMain/kotlin/uk/gov/hmrc/.keep b/src/jvmMain/kotlin/uk/gov/hmrc/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/src/jvmMain/resources/.keep b/src/jvmMain/resources/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/src/jvmTest/kotlin/uk/gov/hmrc/.keep b/src/jvmTest/kotlin/uk/gov/hmrc/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/src/jvmTest/resources/.keep b/src/jvmTest/resources/.keep deleted file mode 100644 index e69de29..0000000