Skip to content

Commit

Permalink
Add_Detekt,_Jacoco,_Junit_test_and_Swagger_open_API (#15)
Browse files Browse the repository at this point in the history
* Fixed bug in update auth password rest endpoint

* Add detekt (#16)

* Added detekt config

* Added detekt in project

* Changes regarding to detekt

* Added jacoco (#17)

* Add junit tests (#18)

* Added sign up tests

* Add login tests

* Added update and delete auth tests

* Minor update in Application test

* Detekt check fixed

* Added swagger (#19)
  • Loading branch information
Harsh3305 authored Jan 26, 2023
1 parent 5d2988c commit 596432e
Show file tree
Hide file tree
Showing 9 changed files with 557 additions and 11 deletions.
31 changes: 29 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

import io.gitlab.arturbosch.detekt.Detekt
plugins {
id("org.springframework.boot") version "3.0.2"
id("io.spring.dependency-management") version "1.1.0"
id("io.gitlab.arturbosch.detekt").version("1.22.0") // This is to add detekt
id("jacoco")// Add Jacoco
kotlin("jvm") version "1.7.22"
kotlin("plugin.spring") version "1.7.22"
}
Expand All @@ -23,10 +25,14 @@ dependencies {
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor")
detektPlugins ("io.gitlab.arturbosch.detekt:detekt-formatting:1.22.0")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("io.projectreactor:reactor-test")
}

detekt {
toolVersion = "1.22.0"
config = files("config/detekt/detekt.yml")
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
Expand All @@ -36,4 +42,25 @@ tasks.withType<KotlinCompile> {

tasks.withType<Test> {
useJUnitPlatform()
finalizedBy("jacocoTestCoverageVerification")
}
/*
* Jacoco configs*/
tasks.jacocoTestCoverageVerification {
violationRules {
rule {
excludes = listOf(
"com.hrv.mart.user.repository.UserRepository.kt.*"
)
limit {
minimum = "0.9".toBigDecimal()
}
}
}
}
tasks.jacocoTestReport{
reports {
html.required.set(true)
generate()
}
}
274 changes: 274 additions & 0 deletions config/detekt/detekt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,274 @@
comments:
CommentOverPrivateProperty:
active: true
UndocumentedPublicClass:
active: true
excludes: ['**/*.kt']
includes: ['**/detekt-api/src/main/**/api/*.kt']
UndocumentedPublicFunction:
active: true
excludes: ['**/*.kt']
includes: ['**/detekt-api/src/main/**/api/*.kt']

complexity:
StringLiteralDuplication:
active: true
excludes: ['**/test/**', '**/*Test.kt', '**/*Spec.kt']
threshold: 5
ignoreAnnotation: true
excludeStringsWithLessThan5Characters: true
ignoreStringsRegex: '$^'
ComplexInterface:
active: true
threshold: 10
includeStaticDeclarations: false
includePrivateDeclarations: false
CyclomaticComplexMethod:
active: true
ignoreSingleWhenExpression: true
LargeClass:
active: true
excludes: ['**/test/**', '**/*.Test.kt', '**/*.Spec.kt']
MethodOverloading:
active: true
TooManyFunctions:
excludes: ['**/test/**', '**/functionalTest/**']

coroutines:
active: true
GlobalCoroutineUsage:
active: true
RedundantSuspendModifier:
active: true
SleepInsteadOfDelay:
active: true
SuspendFunWithFlowReturnType:
active: true

exceptions:
InstanceOfCheckForException:
active: true
NotImplementedDeclaration:
active: true
ObjectExtendsThrowable:
active: true
RethrowCaughtException:
active: true
ReturnFromFinally:
active: true
ThrowingExceptionFromFinally:
active: true
ThrowingExceptionInMain:
active: true
ThrowingExceptionsWithoutMessageOrCause:
active: true
ThrowingNewInstanceOfSameException:
active: true

formatting:
active: true
android: false
autoCorrect: true
ContextReceiverMapping:
active: true
Filename:
active: false
FunctionReturnTypeSpacing:
active: false #changed to false
FunctionStartOfBodySpacing:
active: true
MaximumLineLength:
active: false
NullableTypeSpacing:
active: true
ParameterListSpacing:
active: true
SpacingBetweenFunctionNameAndOpeningParenthesis:
active: true
TypeParameterListSpacing:
active: true

naming:
ClassNaming:
excludes: ['**/*Spec.kt']
FunctionNaming:
active: true
excludes:
- '**/test/**'
- '**/androidTest/**'
- '**/commonTest/**'
- '**/functionalTest/**'
- '**/jvmTest/**'
- '**/jsTest/**'
- '**/iosTest/**'
TopLevelPropertyNaming:
constantPattern: '[a-z][_A-Za-z0-9]*|[A-Z][_A-Z0-9]*'
InvalidPackageDeclaration:
active: true
excludes: ['**/build-logic/**/*.kt', '**/*.kts']
NoNameShadowing:
active: true
NonBooleanPropertyPrefixedWithIs:
active: true
VariableMaxLength:
active: true
VariableMinLength:
active: true

performance:
SpreadOperator:
excludes: ['**/test/**', '**/functionalTest/**']

potential-bugs:
AvoidReferentialEquality:
active: true
DontDowncastCollectionTypes:
active: true
DoubleMutabilityForCollection:
active: false
ElseCaseInsteadOfExhaustiveWhen:
active: true
ExitOutsideMain:
active: false
HasPlatformType:
active: true
IgnoredReturnValue:
active: true
ImplicitUnitReturnType:
active: true
MapGetWithNotNullAssertionOperator:
active: true
UnconditionalJumpStatementInLoop:
active: true
UnreachableCatchBlock:
active: true
UnsafeCast:
active: true
excludes: ['**/test/**', '**/*.Test.kt', '**/*.Spec.kt']
UselessPostfixExpression:
active: true

style:
CanBeNonNullable:
active: true
CascadingCallWrapping:
active: true
ClassOrdering:
active: true
CollapsibleIfStatements:
active: true
DestructuringDeclarationWithTooManyEntries:
active: true
EqualsOnSignatureLine:
active: true
ExplicitCollectionElementAccessMethod:
active: true
ExplicitItLambdaParameter:
active: true
ForbiddenComment:
active: true
values:
- 'TODO:'
- 'FIXME:'
- 'STOPSHIP:'
- '@author'
- '@requiresTypeResolution'
excludes: ['**/detekt-rules-style/**/ForbiddenComment.kt']
ForbiddenImport:
active: true
imports:
- value: 'org.assertj.core.api.Assertions'
reason: 'Import Assertions.assertThat instead.'
- value: 'org.junit.jupiter.api.Assertions*'
reason: 'Use AssertJ assertions instead.'
ForbiddenMethodCall:
active: true
methods:
- 'kotlin.io.print'
- 'kotlin.io.println'
- 'java.net.URL.openStream'
- 'java.lang.Class.getResourceAsStream'
- 'java.lang.ClassLoader.getResourceAsStream'
- 'org.jetbrains.kotlin.diagnostics.DiagnosticUtils.getLineAndColumnInPsiFile'
ForbiddenVoid:
active: true
MagicNumber:
excludes: ['**/test/**', '**/*Test.kt', '**/*Spec.kt']
ignorePropertyDeclaration: true
ignoreAnnotation: true
ignoreEnums: true
ignoreNumbers:
- '-1'
- '0'
- '1'
- '2'
- '100'
- '1000'
MandatoryBracesLoops:
active: true
MaxLineLength:
active: true
excludes: ['**/test/**', '**/*Test.kt', '**/*Spec.kt']
excludeCommentStatements: true
NestedClassesVisibility:
active: true
ObjectLiteralToLambda:
active: true
PreferToOverPairSyntax:
active: true
RedundantExplicitType:
active: true
RedundantHigherOrderMapUsage:
active: true
RedundantVisibilityModifierRule:
active: true
ReturnCount:
active: true
excludeGuardClauses: true
SpacingBetweenPackageAndImports:
active: true
TrimMultilineRawString:
active: true
UnderscoresInNumericLiterals:
active: true
UnnecessaryAnnotationUseSiteTarget:
active: true
UnnecessaryFilter:
active: true
UnnecessaryLet:
active: true
UnnecessaryInnerClass:
active: true
ignoreAnnotated: ['Nested']
UntilInsteadOfRangeTo:
active: true
UnusedImports:
active: false # formatting already have this rule enabled
UnusedPrivateMember:
active: true
allowedNames: '(_|ignored|expected)'
UseAnyOrNoneInsteadOfFind:
active: true
UseCheckOrError:
active: true
UseEmptyCounterpart:
active: true
UseIfEmptyOrIfBlank:
active: true
UseIsNullOrEmpty:
active: true
UseOrEmpty:
active: true
UseRequire:
active: true
UseRequireNotNull:
active: true
VarCouldBeVal:
active: true
ignoreAnnotated: ['Parameter']
WildcardImport:
active: true
excludeImports: [
org.springframework.web.bind.annotation.*,
java.util.*
]
Loading

0 comments on commit 596432e

Please sign in to comment.