Skip to content

Commit

Permalink
Merge branch 'master' into com.gradleup.shadow
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-dingemans authored Aug 9, 2024
2 parents 3abf43a + 2b7a885 commit d884dd2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
8 changes: 4 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
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" }
checksum = "org.gradle.crypto.checksum:1.4.0"
shadow = "com.gradleup.shadow:8.3.0"
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" }
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}

0 comments on commit d884dd2

Please sign in to comment.