From b2c993db4b81bc729dc20897e2f3cd7c02d2f0e6 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 9 Aug 2024 17:12:29 +0200 Subject: [PATCH 1/4] Update plugin kotlinx-binary-compatibiltiy-validator to v0.16.3 (#2759) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 9bdacd3815..33bc65aed2 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -10,7 +10,7 @@ kotlinDev = "2.0.0" kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } checksum = "org.gradle.crypto.checksum:1.4.0" shadow = "com.github.johnrengelman.shadow:8.1.1" -kotlinx-binary-compatibiltiy-validator = "org.jetbrains.kotlinx.binary-compatibility-validator:0.16.2" +kotlinx-binary-compatibiltiy-validator = "org.jetbrains.kotlinx.binary-compatibility-validator:0.16.3" [libraries] kotlin-compiler = { module = "org.jetbrains.kotlin:kotlin-compiler-embeddable", version.ref = "kotlin" } From 9af128636d7452dd00526505bbfed3e9a5191609 Mon Sep 17 00:00:00 2001 From: Paul Dingemans Date: Fri, 9 Aug 2024 17:13:49 +0200 Subject: [PATCH 2/4] Ignore properties starting with `_` in `backing-property-naming` rule (#2753) Name of an overridden property can only be changed by changing the name of the base property. Closes #2748 --- .../standard/rules/BackingPropertyNamingRule.kt | 6 +++++- .../rules/BackingPropertyNamingRuleTest.kt | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/ktlint-ruleset-standard/src/main/kotlin/com/pinterest/ktlint/ruleset/standard/rules/BackingPropertyNamingRule.kt b/ktlint-ruleset-standard/src/main/kotlin/com/pinterest/ktlint/ruleset/standard/rules/BackingPropertyNamingRule.kt index cc81eda298..ce6118bb44 100644 --- a/ktlint-ruleset-standard/src/main/kotlin/com/pinterest/ktlint/ruleset/standard/rules/BackingPropertyNamingRule.kt +++ b/ktlint-ruleset-standard/src/main/kotlin/com/pinterest/ktlint/ruleset/standard/rules/BackingPropertyNamingRule.kt @@ -4,6 +4,7 @@ import com.pinterest.ktlint.rule.engine.core.api.AutocorrectDecision import com.pinterest.ktlint.rule.engine.core.api.ElementType.FUN import com.pinterest.ktlint.rule.engine.core.api.ElementType.IDENTIFIER import com.pinterest.ktlint.rule.engine.core.api.ElementType.INTERNAL_KEYWORD +import com.pinterest.ktlint.rule.engine.core.api.ElementType.OVERRIDE_KEYWORD import com.pinterest.ktlint.rule.engine.core.api.ElementType.PRIVATE_KEYWORD import com.pinterest.ktlint.rule.engine.core.api.ElementType.PROPERTY import com.pinterest.ktlint.rule.engine.core.api.ElementType.PROTECTED_KEYWORD @@ -53,7 +54,10 @@ public class BackingPropertyNamingRule : property .findChildByType(IDENTIFIER) ?.takeIf { it.text.startsWith("_") } - ?.let { identifier -> + ?.takeUnless { + // Do not report overridden properties as they can only be changed by changing the base property + it.treeParent.hasModifier(OVERRIDE_KEYWORD) + }?.let { identifier -> visitBackingProperty(identifier, emit) } } diff --git a/ktlint-ruleset-standard/src/test/kotlin/com/pinterest/ktlint/ruleset/standard/rules/BackingPropertyNamingRuleTest.kt b/ktlint-ruleset-standard/src/test/kotlin/com/pinterest/ktlint/ruleset/standard/rules/BackingPropertyNamingRuleTest.kt index 40cca61c9d..6d33a7cdcf 100644 --- a/ktlint-ruleset-standard/src/test/kotlin/com/pinterest/ktlint/ruleset/standard/rules/BackingPropertyNamingRuleTest.kt +++ b/ktlint-ruleset-standard/src/test/kotlin/com/pinterest/ktlint/ruleset/standard/rules/BackingPropertyNamingRuleTest.kt @@ -345,4 +345,18 @@ class BackingPropertyNamingRuleTest { """.trimIndent() backingPropertyNamingRuleAssertThat(code).hasNoLintViolations() } + + @Test + fun `Issue 2748 - Given an override property with name starting with '_' then do not report a violation`() { + val code = + """ + // The property "__foo" in example below can be defined in an external dependency, which can not be changed. Even in case it is + // a (internal) dependency that can be changed, the violation should only be reported at the base property, but on the overrides + val fooBar = + object : FooBar { + override val __foo = "foo" + } + """.trimIndent() + backingPropertyNamingRuleAssertThat(code).hasNoLintViolations() + } } From 5baa5d2ead27313770f53be11d5acd6a4450c8ac Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 9 Aug 2024 17:14:29 +0200 Subject: [PATCH 3/4] Update kotlin monorepo to v2.0.10 (#2761) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- gradle/libs.versions.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 33bc65aed2..162dd975df 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -3,8 +3,8 @@ java-compilation = "21" # The java-target version is the lowest supported LTS version of Java. Jar's produced are bytecode compatible with this version. java-target = "8" -kotlin = "2.0.0" -kotlinDev = "2.0.0" +kotlin = "2.0.10" +kotlinDev = "2.0.10" [plugins] kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } From 2b7a8852ac23cdb7dccb354453c70b43991bcda5 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 9 Aug 2024 17:14:57 +0200 Subject: [PATCH 4/4] fix(deps): update dependency org.slf4j:slf4j-simple to v2.0.15 (#2762) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 162dd975df..55cdf99acb 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -20,7 +20,7 @@ clikt = "com.github.ajalt.clikt:clikt:4.4.0" dokka = "org.jetbrains.dokka:dokka-gradle-plugin:1.9.20" ec4j = "org.ec4j.core:ec4j-core:0.3.0" logging = "io.github.oshai:kotlin-logging-jvm:7.0.0" -slf4j = "org.slf4j:slf4j-simple:2.0.13" +slf4j = "org.slf4j:slf4j-simple:2.0.15" poko = "dev.drewhamilton.poko:poko-gradle-plugin:0.16.0" # Use logback-classic as the logger for kotlin-logging / slf4j as it allow changing the log level at runtime. # TODO: Update "renovate.json" once logback-classic is updated to 1.4 (once java8 support for ktlint is dropped)