Skip to content

Commit 36445e0

Browse files
committed
Run the build on JDK 21 and fix what detekt then found
gradle/gradle-daemon-jvm.properties pinned the daemon to JDK 25, so every build ran there whatever JAVA_HOME said. detekt 1.23 embeds a Kotlin compiler that cannot parse a 25.x version string and died with 'IllegalArgumentException: 25.0.3' before analysing anything, which is what failed CI. Dropping the generated toolchainUrl entries with it: they pointed at JDK 25 downloads and would be wrong for a 21 request. Gradle now uses the locally installed 21 that dev machines and the runner already have. With detekt actually running, three real findings surfaced and one config bug: - BADGE_ALPHA and BORDER_ALPHA in UrgencyStyle.kt were dead - MagicNumber listed excludes, which replaces detekt's defaults instead of adding to them, so the test sources lost their exemption and 55 deliberate literals in tests were flagged - parseIsoish trips ReturnCount at 7 returns, all of them guard clauses, which is the house style; guards are no longer counted Also renames UrgencyBadge.kt to UrgencyStyle.kt. It holds no UrgencyBadge, which ktlint's filename rule caught and which had been failing since the file was written.
1 parent e91b2ef commit 36445e0

4 files changed

Lines changed: 26 additions & 17 deletions

File tree

build.gradle.kts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ allprojects {
2222
config.setFrom(rootProject.files("config/detekt/detekt.yml"))
2323
parallel = true
2424
}
25+
26+
// detekt 1.23 embeds a Kotlin compiler whose IntelliJ `JavaVersion.parse` cannot read a
27+
// JDK 25 version string, and dies with `IllegalArgumentException: 25.0.3` before it
28+
// analyses anything. The task has no `javaLauncher`, so the JVM is pinned in
29+
// gradle.properties instead. This only sets the bytecode target.
30+
tasks.withType<io.gitlab.arturbosch.detekt.Detekt>().configureEach {
31+
jvmTarget = "21"
32+
}
2533
}
2634

2735
/**

composeApp/src/main/kotlin/com/anish/expirydatereminder/ui/items/UrgencyBadge.kt renamed to composeApp/src/main/kotlin/com/anish/expirydatereminder/ui/items/UrgencyStyle.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,3 @@ fun urgencyStyle(status: ExpiryStatus): UrgencyStyle {
5151
)
5252
}
5353
}
54-
55-
private const val BADGE_ALPHA = 0.10f
56-
private const val BORDER_ALPHA = 0.22f

config/detekt/detekt.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ naming:
1313
ignoreAnnotated: ['Composable']
1414
MatchingDeclarationName:
1515
# Several files deliberately group a component with the small types that only it uses
16-
# (SystemCamera.kt/CameraCapture, UrgencyBadge.kt/UrgencyStyle). One file per declaration
16+
# (SystemCamera.kt/CameraCapture). One file per declaration
1717
# would scatter them.
1818
active: false
1919

@@ -37,13 +37,21 @@ style:
3737
# :shared — the database, migration and parser code, where a bare literal is a real risk.
3838
ignoreAnnotated: ['Composable']
3939
ignorePropertyDeclaration: true
40+
# Listing excludes replaces detekt's defaults rather than adding to them, which is how
41+
# the test source sets ended up in scope. Tests are full of deliberate literals — dates,
42+
# day counts, row ids — and naming each one hides what the case is actually about.
4043
excludes:
4144
- '**/ui/**'
4245
- '**/widget/**'
46+
- '**/test/**'
47+
- '**/androidTest/**'
48+
- '**/commonTest/**'
4349
MaxLineLength:
4450
# Matches .editorconfig, so ktlint and detekt agree.
4551
maxLineLength: 120
4652
ReturnCount:
4753
# Guard clauses and early returns are the house style; a parser that validates five
48-
# fields in sequence reads better as five early returns than as nested ifs.
54+
# fields in sequence reads better as five early returns than as nested ifs, so the
55+
# guards are not counted against the limit at all.
4956
max: 6
57+
excludeGuardClauses: true
Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
#This file is generated by updateDaemonJvm
2-
toolchainUrl.FREE_BSD.AARCH64=https\://api.foojay.io/disco/v3.0/ids/cf726b4a1c84b50457225f9bba6d7650/redirect
3-
toolchainUrl.FREE_BSD.X86_64=https\://api.foojay.io/disco/v3.0/ids/fa1e318c287360478e3c83a9a3ef1007/redirect
4-
toolchainUrl.LINUX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/cf726b4a1c84b50457225f9bba6d7650/redirect
5-
toolchainUrl.LINUX.X86_64=https\://api.foojay.io/disco/v3.0/ids/fa1e318c287360478e3c83a9a3ef1007/redirect
6-
toolchainUrl.MAC_OS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/c2dd35c9d0aaf0ba6ad0791320f99dfc/redirect
7-
toolchainUrl.MAC_OS.X86_64=https\://api.foojay.io/disco/v3.0/ids/e5810bd7fd1f8a586644409d395a7e55/redirect
8-
toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/cf726b4a1c84b50457225f9bba6d7650/redirect
9-
toolchainUrl.UNIX.X86_64=https\://api.foojay.io/disco/v3.0/ids/fa1e318c287360478e3c83a9a3ef1007/redirect
10-
toolchainUrl.WINDOWS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/7b3c4877c0749019e6805bb61e421497/redirect
11-
toolchainUrl.WINDOWS.X86_64=https\://api.foojay.io/disco/v3.0/ids/d76df094a9cbbabd3b08251f9e61444a/redirect
12-
toolchainVersion=25
1+
# The JVM the Gradle daemon itself runs on, which is not the same thing as the JVM the
2+
# code targets. This said 25, so every build ran on JDK 25 whatever JAVA_HOME pointed at,
3+
# and detekt 1.23 dies on a version string that new before it analyses anything.
4+
#
5+
# The generated toolchainUrl entries are gone with it. They pointed at JDK 25 downloads
6+
# and would be wrong for a 21 request. Without them Gradle uses a locally installed 21,
7+
# which is what both a dev machine and the CI runner already have.
8+
toolchainVersion=21

0 commit comments

Comments
 (0)