Skip to content

Commit 8ec407f

Browse files
committed
Revisit detekt configuration
1 parent 846a699 commit 8ec407f

File tree

6 files changed

+37
-213
lines changed

6 files changed

+37
-213
lines changed

buildSrc/src/main/kotlin/sb-ot-demo.kotlin-conventions.gradle.kts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ detekt {
4545
}
4646

4747
tasks {
48-
test {
48+
val detektTask = named("detekt") {
4949
dependsOn(detektMain, detektTest)
5050
}
51+
52+
test {
53+
dependsOn(detektTask)
54+
}
5155
}

config/detekt/detekt.yml

Lines changed: 26 additions & 209 deletions
Original file line numberDiff line numberDiff line change
@@ -2,219 +2,36 @@ performance:
22
SpreadOperator:
33
active: false
44

5-
formatting:
6-
active: true
7-
android: false
8-
AnnotationOnSeparateLine:
9-
active: false
10-
ChainWrapping:
11-
active: true
12-
CommentSpacing:
13-
active: true
14-
Filename:
15-
active: true
16-
FinalNewline:
17-
active: true
18-
ImportOrdering:
5+
libraries:
6+
LibraryEntitiesShouldNotBePublic:
197
active: false
20-
Indentation:
21-
active: true
22-
indentSize: 4
23-
# continuationIndentSize: 4
8+
9+
formatting:
2410
MaximumLineLength:
25-
active: true
26-
maxLineLength: 240
27-
ModifierOrdering:
28-
active: true
29-
MultiLineIfElse:
30-
active: true
31-
NoBlankLineBeforeRbrace:
32-
active: true
33-
NoConsecutiveBlankLines:
34-
active: true
35-
NoEmptyClassBody:
36-
active: true
37-
NoLineBreakAfterElse:
38-
active: true
39-
NoLineBreakBeforeAssignment:
40-
active: true
41-
NoMultipleSpaces:
42-
active: true
43-
NoSemicolons:
44-
active: true
45-
NoTrailingSpaces:
46-
active: true
47-
NoUnitReturn:
48-
active: true
49-
NoUnusedImports:
50-
active: true
51-
NoWildcardImports:
52-
active: true
53-
PackageName:
54-
active: true
55-
ParameterListWrapping:
56-
active: true
57-
# indentSize: 4
58-
SpacingAroundColon:
59-
active: true
60-
SpacingAroundComma:
61-
active: true
62-
SpacingAroundCurly:
63-
active: true
64-
SpacingAroundDot:
65-
active: true
66-
SpacingAroundKeyword:
67-
active: true
68-
SpacingAroundOperators:
69-
active: true
70-
SpacingAroundParens:
71-
active: true
72-
SpacingAroundRangeOperator:
73-
active: true
74-
StringTemplate:
75-
active: true
11+
maxLineLength: 200
7612

7713
style:
78-
active: true
79-
CollapsibleIfStatements:
80-
active: false
81-
DataClassContainsFunctions:
82-
active: false
83-
conversionFunctionPrefix: ['to']
84-
DataClassShouldBeImmutable:
85-
active: false
86-
EqualsNullCall:
87-
active: true
88-
EqualsOnSignatureLine:
89-
active: false
90-
ExplicitItLambdaParameter:
91-
active: false
92-
ExpressionBodySyntax:
93-
active: false
94-
includeLineWrapping: false
95-
ForbiddenComment:
96-
active: false
97-
comments: [ 'TODO:','FIXME:','STOPSHIP:' ]
98-
allowedPatterns: ""
99-
ForbiddenImport:
100-
active: false
101-
imports: [ ]
102-
forbiddenPatterns: ""
103-
ForbiddenVoid:
104-
active: false
105-
ignoreOverridden: false
106-
ignoreUsageInGenerics: false
107-
FunctionOnlyReturningConstant:
108-
active: true
109-
ignoreOverridableFunction: true
110-
excludedFunctions: [ 'describeContents' ]
111-
LoopWithTooManyJumpStatements:
112-
active: true
113-
maxJumpCount: 1
114-
MagicNumber:
115-
active: true
116-
excludes: [ "**/test/**","**/*.Test.kt","**/*.Spec.kt","**/*.Spek.kt","**/*Properties.kt","**/*Configuration.kt" ]
117-
ignoreNumbers: [ '-1','0','1','2' ]
118-
ignoreHashCodeFunction: true
119-
ignorePropertyDeclaration: false
120-
ignoreLocalVariableDeclaration: false
121-
ignoreConstantDeclaration: true
122-
ignoreCompanionObjectPropertyDeclaration: true
123-
ignoreAnnotation: false
124-
ignoreNamedArgument: true
125-
ignoreEnums: false
126-
ignoreRanges: false
12714
MaxLineLength:
128-
active: true
129-
maxLineLength: 240
130-
excludePackageStatements: true
131-
excludeImportStatements: true
132-
excludeCommentStatements: false
133-
MayBeConst:
134-
active: true
135-
ModifierOrder:
136-
active: true
137-
NestedClassesVisibility:
138-
active: false
139-
NewLineAtEndOfFile:
140-
active: true
141-
NoTabs:
142-
active: true
143-
OptionalAbstractKeyword:
144-
active: true
145-
OptionalUnit:
146-
active: false
147-
PreferToOverPairSyntax:
148-
active: true
149-
ProtectedMemberInFinalClass:
150-
active: true
151-
RedundantExplicitType:
152-
active: false
153-
RedundantVisibilityModifierRule:
154-
active: true
155-
ReturnCount:
156-
active: true
157-
max: 2
158-
excludedFunctions: [ "equals" ]
159-
excludeLabeled: false
160-
excludeReturnFromLambda: true
161-
excludeGuardClauses: false
162-
SafeCast:
163-
active: true
164-
SerialVersionUIDInSerializableClass:
165-
active: false
166-
SpacingBetweenPackageAndImports:
167-
active: false
168-
ThrowsCount:
169-
active: true
170-
max: 2
171-
TrailingWhitespace:
172-
active: false
173-
UnderscoresInNumericLiterals:
174-
active: false
175-
acceptableLength: 5
176-
UnnecessaryAbstractClass:
177-
active: false
178-
UnnecessaryApply:
179-
active: false
180-
UnnecessaryInheritance:
181-
active: true
182-
UnnecessaryLet:
183-
active: false
184-
UnnecessaryParentheses:
185-
active: false
186-
UntilInsteadOfRangeTo:
187-
active: false
188-
UnusedImports:
189-
active: true
190-
UnusedPrivateClass:
191-
active: true
192-
UnusedPrivateMember:
193-
active: true
194-
allowedNames: "(_|ignored|expected|serialVersionUID)"
195-
UseArrayLiteralsInAnnotations:
196-
active: false
197-
UseCheckOrError:
198-
active: false
199-
UseDataClass:
200-
active: false
201-
ignoreAnnotated: [ ]
202-
allowVars: false
203-
UseIfInsteadOfWhen:
204-
active: false
205-
UseRequire:
206-
active: false
207-
UselessCallOnNotNull:
208-
active: true
209-
UtilityClassWithPublicConstructor:
210-
active: true
15+
maxLineLength: 200
21116
VarCouldBeVal:
212-
active: false
213-
WildcardImport:
17+
ignoreLateinitVar: true
18+
ForbiddenImport:
21419
active: true
215-
216-
libraries:
217-
LibraryEntitiesShouldNotBePublic:
218-
active: false
219-
ForbiddenPublicDataClass:
220-
active: false
20+
imports: []
21+
forbiddenPatterns: 'org\.junit\.jupiter\.api\.Assertions|org\.hamcrest'
22+
ForbiddenMethodCall:
23+
active: true
24+
methods:
25+
- 'kotlin.assert'
26+
- 'org.junit.jupiter.api.Assertions.assertEquals'
27+
- 'org.junit.jupiter.api.Assertions.assertTrue'
28+
- 'org.junit.jupiter.api.Assertions.assertFalse'
29+
- 'org.junit.jupiter.api.Assertions.assertNull'
30+
- 'org.junit.jupiter.api.Assertions.assertNotNull'
31+
- 'org.junit.jupiter.api.Assertions.assertArrayEquals'
32+
- 'org.junit.jupiter.api.Assertions.assertIterableEquals'
33+
- 'org.junit.jupiter.api.Assertions.assertNotEquals'
34+
- 'org.junit.jupiter.api.Assertions.assertSame'
35+
- 'org.junit.jupiter.api.Assertions.assertNotSame'
36+
- 'org.junit.jupiter.api.Assertions.assertAll'
37+
- 'org.junit.jupiter.api.Assertions.assertThrowsExactly'

spring-boot-3-demo-app-kotlin/src/main/kotlin/io/github/mfvanek/spring/boot3/kotlin/test/service/dto/CurrentTime.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
package io.github.mfvanek.spring.boot3.kotlin.test.service.dto
99

10+
@Suppress("ForbiddenPublicDataClass")
1011
data class CurrentTime(
1112
val datetime: ParsedDateTime
1213
)

spring-boot-3-demo-app-kotlin/src/main/kotlin/io/github/mfvanek/spring/boot3/kotlin/test/service/dto/ParsedDateTime.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ package io.github.mfvanek.spring.boot3.kotlin.test.service.dto
99

1010
import java.time.LocalDateTime
1111

12+
@Suppress("ForbiddenPublicDataClass")
1213
data class ParsedDateTime(
1314
val year: Int,
1415
val monthValue: Int,

spring-boot-3-demo-app-kotlin/src/test/kotlin/io/github/mfvanek/spring/boot3/kotlin/test/service/PublicApiServiceTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ import io.github.mfvanek.spring.boot3.kotlin.test.support.TestBase
66
import io.micrometer.observation.Observation
77
import io.micrometer.observation.ObservationRegistry
88
import io.micrometer.tracing.Tracer
9-
import java.time.LocalDateTime
10-
import java.time.temporal.ChronoUnit
11-
import java.util.Locale
129
import org.assertj.core.api.Assertions.assertThat
1310
import org.junit.jupiter.api.Test
1411
import org.junit.jupiter.api.extension.ExtendWith
1512
import org.springframework.beans.factory.annotation.Autowired
1613
import org.springframework.boot.test.system.CapturedOutput
1714
import org.springframework.boot.test.system.OutputCaptureExtension
15+
import java.time.LocalDateTime
16+
import java.time.temporal.ChronoUnit
17+
import java.util.Locale
1818

1919
@ExtendWith(OutputCaptureExtension::class)
2020
class PublicApiServiceTest : TestBase() {

spring-boot-3-demo-app-kotlin/src/test/kotlin/io/github/mfvanek/spring/boot3/kotlin/test/support/TestBase.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import org.springframework.test.web.reactive.server.WebTestClient
1717
import java.time.Clock
1818
import java.util.*
1919

20+
@Suppress("UnnecessaryAbstractClass")
2021
@ActiveProfiles("test")
2122
@AutoConfigureObservability
2223
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)

0 commit comments

Comments
 (0)