Skip to content

Commit 2c4f074

Browse files
committed
Upgrade Kotlin to 1.8.22
Upgrade ksp to 1.8.22-1.0.11 Upgrade detekt to 1.23 Edit detekt.yml for new rules Upgrade log4j to 2.20.0 Upgrade auto-service-annotations to 1.1.1 Upgrade auto-service-ksp to 1.1.0 Upgrade commons-io to 2.13.0 Upgrade truth to 1.1.5 Upgrade jimfs to 1.3.0
1 parent cac2035 commit 2c4f074

4 files changed

Lines changed: 119 additions & 79 deletions

File tree

build.gradle.kts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import io.gitlab.arturbosch.detekt.Detekt
2+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
23
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
34

45
plugins {
56
alias(libs.plugins.ktlint) apply false
67
alias(libs.plugins.detekt)
7-
kotlin("jvm") version "1.7.21" apply false
8+
kotlin("jvm") version "1.8.22" apply false
89
}
910

1011
subprojects {
@@ -13,18 +14,19 @@ subprojects {
1314

1415
group = "com.pkware.filesystem"
1516

16-
val kotlinJvmTarget = "1.8"
17-
1817
repositories {
1918
mavenCentral()
2019
}
2120

22-
tasks.withType<KotlinCompile> {
23-
kotlinOptions {
24-
jvmTarget = kotlinJvmTarget
25-
freeCompilerArgs = listOf(
21+
tasks.withType<KotlinCompile>().configureEach {
22+
compilerOptions {
23+
24+
jvmTarget.set(JvmTarget.JVM_1_8)
25+
26+
freeCompilerArgs.addAll(
2627
"-Xjvm-default=all",
27-
"-Xopt-in=kotlin.RequiresOptIn",
28+
"-Xinline-classes",
29+
"-opt-in=kotlin.contracts.ExperimentalContracts",
2830
"-Xjsr305=strict",
2931

3032
// Ensure assertions don't add performance cost. See https://youtrack.jetbrains.com/issue/KT-22292
@@ -33,10 +35,14 @@ subprojects {
3335
}
3436
}
3537

38+
dependencies {
39+
detektPlugins(project.dependencies.create("com.pkware.detekt:import-extension:1.1.0"))
40+
}
41+
3642
tasks.withType<Test> { useJUnitPlatform() }
3743

3844
tasks.withType<Detekt>().configureEach {
39-
jvmTarget = kotlinJvmTarget
45+
jvmTarget = tasks.named<KotlinCompile>("compileKotlin").get().compilerOptions.jvmTarget.get().target
4046
parallel = true
4147
config.from(rootProject.file("detekt.yml"))
4248
buildUponDefaultConfig = true

detekt.yml

Lines changed: 86 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ config:
44
validation: true
55
warningsAsErrors: true
66

7+
import:
8+
EnforceStaticImport:
9+
active: true
10+
methods:
11+
- 'com.google.common.truth.Truth.assertThat'
12+
- 'org.junit.jupiter.params.provider.Arguments.arguments'
13+
- 'org.apache.logging.log4j.spi.AbstractLogger.CATCHING_MARKER'
14+
715
comments:
816
active: true
917
EndOfSentenceFormat:
@@ -18,11 +26,11 @@ comments:
1826
searchInInnerObject: true
1927
searchInInnerInterface: true
2028
UndocumentedPublicFunction:
21-
excludes: ['**/test/**']
2229
active: true
23-
UndocumentedPublicProperty:
2430
excludes: ['**/test/**']
31+
UndocumentedPublicProperty:
2532
active: true
33+
excludes: ['**/test/**']
2634

2735
complexity:
2836
active: false
@@ -38,14 +46,14 @@ exceptions:
3846
TooGenericExceptionCaught:
3947
active: true
4048
exceptionNames:
41-
- ArrayIndexOutOfBoundsException
42-
- Error
43-
- Exception
44-
- IllegalMonitorStateException
45-
- NullPointerException
46-
- IndexOutOfBoundsException
47-
- RuntimeException
48-
- Throwable
49+
- ArrayIndexOutOfBoundsException
50+
- Error
51+
- Exception
52+
- IllegalMonitorStateException
53+
- NullPointerException
54+
- IndexOutOfBoundsException
55+
- RuntimeException
56+
- Throwable
4957
allowedExceptionNameRegex: '_|(ignore|expected|cause).*'
5058

5159
# The naming rules exclude test classes by default. Since we want naming rules to apply
@@ -76,25 +84,33 @@ potential-bugs:
7684
active: true
7785
DontDowncastCollectionTypes:
7886
active: true
79-
ExitOutsideMain:
87+
DoubleMutabilityForCollection:
8088
active: true
81-
HasPlatformType:
89+
# Test directories might want to reassign variables for result collections
90+
excludes: [ '**/test/**' ]
91+
ElseCaseInsteadOfExhaustiveWhen:
92+
active: true
93+
ExitOutsideMain:
8294
active: true
8395
IgnoredReturnValue:
8496
active: true
85-
restrictToAnnotatedMethods: true
97+
restrictToConfig: true
8698
returnValueAnnotations: ['*.CheckReturnValue', '*.CheckResult']
8799
MapGetWithNotNullAssertionOperator:
88100
active: true
101+
# test directories will want to throw NPE's with maps
102+
excludes: [ '**/test/**' ]
89103
NullableToStringCall:
90104
active: true
91-
UnconditionalJumpStatementInLoop:
105+
ignoreFunction:
106+
- 'toString()'
107+
NullCheckOnMutableProperty:
92108
active: true
93-
UnreachableCatchBlock:
109+
PropertyUsedBeforeDeclaration:
94110
active: true
95-
UnusedUnaryOperator:
111+
UnconditionalJumpStatementInLoop:
96112
active: true
97-
UselessPostfixExpression:
113+
UnnecessaryNotNullCheck:
98114
active: true
99115

100116
style:
@@ -105,14 +121,20 @@ style:
105121
active: true
106122
DataClassShouldBeImmutable:
107123
active: true
124+
DestructuringDeclarationWithTooManyEntries:
125+
active: true
126+
maxDestructuringEntries: 4
127+
DoubleNegativeLambda:
128+
active: true
108129
EqualsOnSignatureLine:
109130
active: true
110131
ExplicitCollectionElementAccessMethod:
111132
active: true
112133
ExpressionBodySyntax:
113134
active: true
114135
includeLineWrapping: true
115-
excludes: ['**/test/**']
136+
ForbiddenAnnotation:
137+
active: true
116138
ForbiddenImport:
117139
active: true
118140
imports:
@@ -122,32 +144,49 @@ style:
122144
- 'org.junit.BeforeClass'
123145
- 'org.junit.After'
124146
- 'org.junit.AfterClass'
125-
forbiddenPatterns: 'junit.framework.*'
147+
- 'org.junit.jupiter.api.Assertions'
148+
forbiddenPatterns: '(?:junit\.framework|org\.junit\.jupiter\.api\.Assertions)\.(?!assertThrows).+'
126149
ForbiddenComment:
127-
active: true
128-
values: ['FIXME', 'STOPSHIP']
150+
comments:
151+
- reason: 'Forbidden FIXME todo marker in comment, please fix the problem.'
152+
value: 'FIXME'
153+
- reason: 'Forbidden STOPSHIP todo marker in comment, please address the problem before shipping the code.'
154+
value: 'STOPSHIP'
155+
- reason: 'Authors are not recorded in KDoc.'
156+
value: '@author'
129157
ForbiddenMethodCall:
130158
active: true
131-
excludes: ['**/test/**']
159+
excludes: [ '**/test/**' ]
132160
methods:
133161
- 'kotlin.io.println'
134162
- 'kotlin.io.print'
135-
ForbiddenPublicDataClass:
136-
active: true
137-
excludes: ['**']
138-
ignorePackages: ['*.internal', '*.internal.*']
163+
- 'java.nio.file.Path.toFile'
164+
- 'org.apache.logging.log4j.Logger.trace'
165+
- 'org.apache.logging.log4j.Logger.debug'
166+
- 'org.apache.logging.log4j.Logger.info'
167+
- 'org.apache.logging.log4j.Logger.warn'
168+
- 'org.apache.logging.log4j.Logger.error'
169+
- 'org.apache.logging.log4j.Logger.fatal'
170+
- 'org.apache.logging.log4j.Logger.log'
171+
- 'org.apache.logging.log4j.Logger.printf'
172+
- 'org.apache.logging.log4j.Logger.isTraceEnabled'
173+
- 'org.apache.logging.log4j.Logger.isDebugEnabled'
174+
- 'org.apache.logging.log4j.Logger.isInfoEnabled'
175+
- 'org.apache.logging.log4j.Logger.isWarnEnabled'
176+
- 'org.apache.logging.log4j.Logger.isErrorEnabled'
177+
- 'org.apache.logging.log4j.Logger.isFatalEnabled'
178+
- 'org.apache.logging.log4j.Logger.isEnabled'
139179
ForbiddenVoid:
140180
active: true
141181
ignoreOverridden: false
142182
ignoreUsageInGenerics: false
143-
LibraryCodeMustSpecifyReturnType:
144-
# Enforced by the compiler
145-
active: false
146-
LibraryEntitiesShouldNotBePublic:
147-
# Enforced by the compiler
148-
active: false
149-
MandatoryBracesIfStatements:
183+
LoopWithTooManyJumpStatements:
184+
maxJumpCount: 3
185+
BracesOnIfStatements:
150186
active: true
187+
BracesOnWhenStatements:
188+
active: true
189+
multiLine: 'necessary'
151190
MandatoryBracesLoops:
152191
active: true
153192
MaxLineLength:
@@ -156,14 +195,11 @@ style:
156195
NewLineAtEndOfFile:
157196
# Specified by editorconfig & enforced by ktlint
158197
active: false
159-
OptionalWhenBraces:
198+
NullableBooleanCheck:
160199
active: true
161200
RedundantExplicitType:
162201
active: true
163-
RedundantHigherOrderMapUsage:
164-
active: true
165202
RedundantVisibilityModifierRule:
166-
# activate to true once https://github.com/detekt/detekt/issues/3874 is resolved
167203
active: false
168204
ReturnCount:
169205
active: false
@@ -172,38 +208,37 @@ style:
172208
UnderscoresInNumericLiterals:
173209
active: true
174210
acceptableLength: 5
175-
UnnecessaryFilter:
211+
UnnecessaryBackticks:
176212
active: true
213+
# Disabled because it produces false positive when using JUnit's @Nested classes
214+
UnnecessaryInnerClass:
215+
active: false
177216
UnnecessaryLet:
178217
active: true
179218
UntilInsteadOfRangeTo:
180219
active: true
181-
UnusedPrivateMember:
182-
active: true
183-
excludes: ['**/test/**']
184-
UseArrayLiteralsInAnnotations:
185-
active: true
186-
UseCheckNotNull:
187-
active: true
188-
UseCheckOrError:
189-
active: true
190220
UseEmptyCounterpart:
191221
active: true
192222
UseIfEmptyOrIfBlank:
193223
active: true
194224
UseIfInsteadOfWhen:
195225
active: true
196-
UseIsNullOrEmpty:
226+
ignoreWhenContainingVariableDeclaration: true
227+
UseLet:
197228
active: true
198-
UseOrEmpty:
229+
UseRequireNotNull:
199230
active: true
200-
UseRequire:
231+
UseSumOfInsteadOfFlatMapSize:
201232
active: true
202-
UseRequireNotNull:
233+
UnnecessaryBracesAroundTrailingLambda:
203234
active: true
204235
WildcardImport:
205236
# Specified by editorconfig and enforced by ktlint
206237
active: false
207238
MagicNumber:
208239
# We usually catch these in code review, and more often than not, the constants aren't very magical
209240
active: false
241+
242+
performance:
243+
UnnecessaryPartOfBinaryExpression:
244+
active: true

file-attribute-caching/src/test/kotlin/com/pkware/filesystem/attributecaching/AttributeCachingFileSystemTests.kt

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,15 @@ class AttributeCachingFileSystemTests {
5050
val waitTimeMillis: Long = 50_000
5151
var caughtException: Exception? = null
5252

53-
fun runTestThread(): Thread {
54-
return thread {
55-
for (i in 1..100_000) {
56-
try {
57-
AttributeCachingFileSystem.wrapping(defaultFileSystem).use { }
58-
} catch (e: Exception) {
59-
// Need to catch and record the exception here because junit does not fail the test if an
60-
// assertion fails inside a thread.
61-
caughtException = e
62-
}
53+
fun runTestThread(): Thread = thread {
54+
@Suppress("UnusedPrivateProperty")
55+
for (i in 1..100_000) {
56+
try {
57+
AttributeCachingFileSystem.wrapping(defaultFileSystem).use { }
58+
} catch (e: Exception) {
59+
// Need to catch and record the exception here because junit does not fail the test if an
60+
// assertion fails inside a thread.
61+
caughtException = e
6362
}
6463
}
6564
}

gradle/libs.versions.toml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
[versions]
2-
junitVersion = "5.8.2"
3-
detektVersion = "1.20.0"
4-
log4jVersion = "2.18.0"
2+
detektVersion = "1.23.1"
3+
junitVersion = "5.10.0"
54
ktlintVersion = "11.5.0"
5+
log4jVersion = "2.20.0"
66

77
[libraries]
8-
commons-io = "commons-io:commons-io:2.11.0"
9-
auto-service-annotations = "com.google.auto.service:auto-service-annotations:1.0.1"
10-
auto-service-ksp = "dev.zacsweers.autoservice:auto-service-ksp:1.0.0"
8+
commons-io = "commons-io:commons-io:2.13.0"
9+
auto-service-annotations = "com.google.auto.service:auto-service-annotations:1.1.1"
10+
auto-service-ksp = "dev.zacsweers.autoservice:auto-service-ksp:1.1.0"
1111
junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junitVersion" }
1212
junit-jupiter-params = { module = "org.junit.jupiter:junit-jupiter-params", version.ref = "junitVersion" }
13-
truth = "com.google.truth:truth:1.1.3"
13+
truth = "com.google.truth:truth:1.1.5"
1414
mockito-kotlin = "org.mockito.kotlin:mockito-kotlin:4.1.0"
1515
log4j-core = { module = "org.apache.logging.log4j:log4j-core", version.ref = "log4jVersion" }
1616
log4j-api = { module = "org.apache.logging.log4j:log4j-api", version.ref = "log4jVersion" }
17-
jimfs = "com.google.jimfs:jimfs:1.2"
17+
jimfs = "com.google.jimfs:jimfs:1.3.0"
1818

1919
[plugins]
20-
ksp = "com.google.devtools.ksp: 1.7.21-1.0.8"
20+
ksp = "com.google.devtools.ksp: 1.8.22-1.0.11"
2121
ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlintVersion" }
2222
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detektVersion" }

0 commit comments

Comments
 (0)