diff --git a/buildSrc/src/main/kotlin/sb-ot-demo.kotlin-conventions.gradle.kts b/buildSrc/src/main/kotlin/sb-ot-demo.kotlin-conventions.gradle.kts index 93f1743e..a101be45 100644 --- a/buildSrc/src/main/kotlin/sb-ot-demo.kotlin-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/sb-ot-demo.kotlin-conventions.gradle.kts @@ -45,7 +45,11 @@ detekt { } tasks { - test { + val detektTask = named("detekt") { dependsOn(detektMain, detektTest) } + + test { + dependsOn(detektTask) + } } diff --git a/config/detekt/detekt.yml b/config/detekt/detekt.yml index 41fedb13..833a77fb 100644 --- a/config/detekt/detekt.yml +++ b/config/detekt/detekt.yml @@ -2,219 +2,36 @@ performance: SpreadOperator: active: false -formatting: - active: true - android: false - AnnotationOnSeparateLine: - active: false - ChainWrapping: - active: true - CommentSpacing: - active: true - Filename: - active: true - FinalNewline: - active: true - ImportOrdering: +libraries: + LibraryEntitiesShouldNotBePublic: active: false - Indentation: - active: true - indentSize: 4 - # continuationIndentSize: 4 + +formatting: MaximumLineLength: - active: true - maxLineLength: 240 - ModifierOrdering: - active: true - MultiLineIfElse: - active: true - NoBlankLineBeforeRbrace: - active: true - NoConsecutiveBlankLines: - active: true - NoEmptyClassBody: - active: true - NoLineBreakAfterElse: - active: true - NoLineBreakBeforeAssignment: - active: true - NoMultipleSpaces: - active: true - NoSemicolons: - active: true - NoTrailingSpaces: - active: true - NoUnitReturn: - active: true - NoUnusedImports: - active: true - NoWildcardImports: - active: true - PackageName: - active: true - ParameterListWrapping: - active: true - # indentSize: 4 - SpacingAroundColon: - active: true - SpacingAroundComma: - active: true - SpacingAroundCurly: - active: true - SpacingAroundDot: - active: true - SpacingAroundKeyword: - active: true - SpacingAroundOperators: - active: true - SpacingAroundParens: - active: true - SpacingAroundRangeOperator: - active: true - StringTemplate: - active: true + maxLineLength: 200 style: - active: true - CollapsibleIfStatements: - active: false - DataClassContainsFunctions: - active: false - conversionFunctionPrefix: ['to'] - DataClassShouldBeImmutable: - active: false - EqualsNullCall: - active: true - EqualsOnSignatureLine: - active: false - ExplicitItLambdaParameter: - active: false - ExpressionBodySyntax: - active: false - includeLineWrapping: false - ForbiddenComment: - active: false - comments: [ 'TODO:','FIXME:','STOPSHIP:' ] - allowedPatterns: "" - ForbiddenImport: - active: false - imports: [ ] - forbiddenPatterns: "" - ForbiddenVoid: - active: false - ignoreOverridden: false - ignoreUsageInGenerics: false - FunctionOnlyReturningConstant: - active: true - ignoreOverridableFunction: true - excludedFunctions: [ 'describeContents' ] - LoopWithTooManyJumpStatements: - active: true - maxJumpCount: 1 - MagicNumber: - active: true - excludes: [ "**/test/**","**/*.Test.kt","**/*.Spec.kt","**/*.Spek.kt","**/*Properties.kt","**/*Configuration.kt" ] - ignoreNumbers: [ '-1','0','1','2' ] - ignoreHashCodeFunction: true - ignorePropertyDeclaration: false - ignoreLocalVariableDeclaration: false - ignoreConstantDeclaration: true - ignoreCompanionObjectPropertyDeclaration: true - ignoreAnnotation: false - ignoreNamedArgument: true - ignoreEnums: false - ignoreRanges: false MaxLineLength: - active: true - maxLineLength: 240 - excludePackageStatements: true - excludeImportStatements: true - excludeCommentStatements: false - MayBeConst: - active: true - ModifierOrder: - active: true - NestedClassesVisibility: - active: false - NewLineAtEndOfFile: - active: true - NoTabs: - active: true - OptionalAbstractKeyword: - active: true - OptionalUnit: - active: false - PreferToOverPairSyntax: - active: true - ProtectedMemberInFinalClass: - active: true - RedundantExplicitType: - active: false - RedundantVisibilityModifierRule: - active: true - ReturnCount: - active: true - max: 2 - excludedFunctions: [ "equals" ] - excludeLabeled: false - excludeReturnFromLambda: true - excludeGuardClauses: false - SafeCast: - active: true - SerialVersionUIDInSerializableClass: - active: false - SpacingBetweenPackageAndImports: - active: false - ThrowsCount: - active: true - max: 2 - TrailingWhitespace: - active: false - UnderscoresInNumericLiterals: - active: false - acceptableLength: 5 - UnnecessaryAbstractClass: - active: false - UnnecessaryApply: - active: false - UnnecessaryInheritance: - active: true - UnnecessaryLet: - active: false - UnnecessaryParentheses: - active: false - UntilInsteadOfRangeTo: - active: false - UnusedImports: - active: true - UnusedPrivateClass: - active: true - UnusedPrivateMember: - active: true - allowedNames: "(_|ignored|expected|serialVersionUID)" - UseArrayLiteralsInAnnotations: - active: false - UseCheckOrError: - active: false - UseDataClass: - active: false - ignoreAnnotated: [ ] - allowVars: false - UseIfInsteadOfWhen: - active: false - UseRequire: - active: false - UselessCallOnNotNull: - active: true - UtilityClassWithPublicConstructor: - active: true + maxLineLength: 200 VarCouldBeVal: - active: false - WildcardImport: + ignoreLateinitVar: true + ForbiddenImport: active: true - -libraries: - LibraryEntitiesShouldNotBePublic: - active: false - ForbiddenPublicDataClass: - active: false + imports: [] + forbiddenPatterns: 'org\.junit\.jupiter\.api\.Assertions|org\.hamcrest' + ForbiddenMethodCall: + active: true + methods: + - 'kotlin.assert' + - 'org.junit.jupiter.api.Assertions.assertEquals' + - 'org.junit.jupiter.api.Assertions.assertTrue' + - 'org.junit.jupiter.api.Assertions.assertFalse' + - 'org.junit.jupiter.api.Assertions.assertNull' + - 'org.junit.jupiter.api.Assertions.assertNotNull' + - 'org.junit.jupiter.api.Assertions.assertArrayEquals' + - 'org.junit.jupiter.api.Assertions.assertIterableEquals' + - 'org.junit.jupiter.api.Assertions.assertNotEquals' + - 'org.junit.jupiter.api.Assertions.assertSame' + - 'org.junit.jupiter.api.Assertions.assertNotSame' + - 'org.junit.jupiter.api.Assertions.assertAll' + - 'org.junit.jupiter.api.Assertions.assertThrowsExactly' diff --git a/spring-boot-3-demo-app-kotlin/src/main/kotlin/io/github/mfvanek/spring/boot3/kotlin/test/service/dto/CurrentTime.kt b/spring-boot-3-demo-app-kotlin/src/main/kotlin/io/github/mfvanek/spring/boot3/kotlin/test/service/dto/CurrentTime.kt index b053b218..5b230973 100644 --- a/spring-boot-3-demo-app-kotlin/src/main/kotlin/io/github/mfvanek/spring/boot3/kotlin/test/service/dto/CurrentTime.kt +++ b/spring-boot-3-demo-app-kotlin/src/main/kotlin/io/github/mfvanek/spring/boot3/kotlin/test/service/dto/CurrentTime.kt @@ -7,6 +7,7 @@ package io.github.mfvanek.spring.boot3.kotlin.test.service.dto +@Suppress("ForbiddenPublicDataClass") data class CurrentTime( val datetime: ParsedDateTime ) diff --git a/spring-boot-3-demo-app-kotlin/src/main/kotlin/io/github/mfvanek/spring/boot3/kotlin/test/service/dto/ParsedDateTime.kt b/spring-boot-3-demo-app-kotlin/src/main/kotlin/io/github/mfvanek/spring/boot3/kotlin/test/service/dto/ParsedDateTime.kt index 5ca5b271..312b2338 100644 --- a/spring-boot-3-demo-app-kotlin/src/main/kotlin/io/github/mfvanek/spring/boot3/kotlin/test/service/dto/ParsedDateTime.kt +++ b/spring-boot-3-demo-app-kotlin/src/main/kotlin/io/github/mfvanek/spring/boot3/kotlin/test/service/dto/ParsedDateTime.kt @@ -9,6 +9,7 @@ package io.github.mfvanek.spring.boot3.kotlin.test.service.dto import java.time.LocalDateTime +@Suppress("ForbiddenPublicDataClass") data class ParsedDateTime( val year: Int, val monthValue: Int, diff --git a/spring-boot-3-demo-app-kotlin/src/test/kotlin/io/github/mfvanek/spring/boot3/kotlin/test/service/PublicApiServiceTest.kt b/spring-boot-3-demo-app-kotlin/src/test/kotlin/io/github/mfvanek/spring/boot3/kotlin/test/service/PublicApiServiceTest.kt index 2c8942dc..a229d439 100644 --- a/spring-boot-3-demo-app-kotlin/src/test/kotlin/io/github/mfvanek/spring/boot3/kotlin/test/service/PublicApiServiceTest.kt +++ b/spring-boot-3-demo-app-kotlin/src/test/kotlin/io/github/mfvanek/spring/boot3/kotlin/test/service/PublicApiServiceTest.kt @@ -6,15 +6,15 @@ import io.github.mfvanek.spring.boot3.kotlin.test.support.TestBase import io.micrometer.observation.Observation import io.micrometer.observation.ObservationRegistry import io.micrometer.tracing.Tracer -import java.time.LocalDateTime -import java.time.temporal.ChronoUnit -import java.util.Locale import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.system.CapturedOutput import org.springframework.boot.test.system.OutputCaptureExtension +import java.time.LocalDateTime +import java.time.temporal.ChronoUnit +import java.util.Locale @ExtendWith(OutputCaptureExtension::class) class PublicApiServiceTest : TestBase() { diff --git a/spring-boot-3-demo-app-kotlin/src/test/kotlin/io/github/mfvanek/spring/boot3/kotlin/test/support/TestBase.kt b/spring-boot-3-demo-app-kotlin/src/test/kotlin/io/github/mfvanek/spring/boot3/kotlin/test/support/TestBase.kt index c5ee1c91..2ba3a557 100644 --- a/spring-boot-3-demo-app-kotlin/src/test/kotlin/io/github/mfvanek/spring/boot3/kotlin/test/support/TestBase.kt +++ b/spring-boot-3-demo-app-kotlin/src/test/kotlin/io/github/mfvanek/spring/boot3/kotlin/test/support/TestBase.kt @@ -17,6 +17,7 @@ import org.springframework.test.web.reactive.server.WebTestClient import java.time.Clock import java.util.* +@Suppress("UnnecessaryAbstractClass") @ActiveProfiles("test") @AutoConfigureObservability @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)