diff --git a/rules/common/src/main/kotlin/io/nlopez/compose/rules/ParameterNaming.kt b/rules/common/src/main/kotlin/io/nlopez/compose/rules/ParameterNaming.kt index 3b89b5c4..c318ff7d 100644 --- a/rules/common/src/main/kotlin/io/nlopez/compose/rules/ParameterNaming.kt +++ b/rules/common/src/main/kotlin/io/nlopez/compose/rules/ParameterNaming.kt @@ -38,7 +38,8 @@ class ParameterNaming : ComposeKtVisitor { } private val String.isPastTense: Boolean - get() = endsWith("ed") || IrregularVerbsInPastTense.any { endsWith(it) } + get() = VerbsPresentTenseEndingInEd.none { endsWith(it) } && + (endsWith("ed") || IrregularVerbsInPastTense.any { endsWith(it) }) companion object { // A list of common irregular verbs in english, excluding those where present tense == past tense, @@ -203,6 +204,28 @@ class ParameterNaming : ComposeKtVisitor { ) } + // A list of verbs whose present tenses ends in -ed + private val VerbsPresentTenseEndingInEd by lazy { + setOf( + "Bed", + "Bleed", + "Embed", + "Exceed", + "Feed", + "Heed", + "Need", + "Proceed", + "Seed", + "Shed", + "Shred", + "Sled", + "Speed", + "Succeed", + "Wed", + "Weed", + ) + } + val LambdaParametersInPresentTense = """ Lambda parameters in a composable function should be in present tense, not past tense. diff --git a/rules/detekt/src/test/kotlin/io/nlopez/compose/rules/detekt/ParameterNamingCheckTest.kt b/rules/detekt/src/test/kotlin/io/nlopez/compose/rules/detekt/ParameterNamingCheckTest.kt index cb536752..e2b11562 100644 --- a/rules/detekt/src/test/kotlin/io/nlopez/compose/rules/detekt/ParameterNamingCheckTest.kt +++ b/rules/detekt/src/test/kotlin/io/nlopez/compose/rules/detekt/ParameterNamingCheckTest.kt @@ -61,7 +61,13 @@ class ParameterNamingCheckTest { val code = """ @Composable - fun A(onClick: () -> Unit, onValueChange: (Int) -> Unit, onWrite: () -> Unit, onPotato: Potato) {} + fun A( + onClick: () -> Unit, + onValueChange: (Int) -> Unit, + onWrite: () -> Unit, + onPotato: Potato, + onEmbed: () -> Unit, + ) {} """.trimIndent() val errors = rule.lint(code) diff --git a/rules/ktlint/src/test/kotlin/io/nlopez/compose/rules/ktlint/ParameterNamingCheckTest.kt b/rules/ktlint/src/test/kotlin/io/nlopez/compose/rules/ktlint/ParameterNamingCheckTest.kt index 6987e1ba..1ddcb3e5 100644 --- a/rules/ktlint/src/test/kotlin/io/nlopez/compose/rules/ktlint/ParameterNamingCheckTest.kt +++ b/rules/ktlint/src/test/kotlin/io/nlopez/compose/rules/ktlint/ParameterNamingCheckTest.kt @@ -69,7 +69,13 @@ class ParameterNamingCheckTest { val code = """ @Composable - fun A(onClick: () -> Unit, onValueChange: (Int) -> Unit, onWrite: () -> Unit, onPotato: Potato) {} + fun A( + onClick: () -> Unit, + onValueChange: (Int) -> Unit, + onWrite: () -> Unit, + onPotato: Potato, + onEmbed: () -> Unit, + ) {} """.trimIndent() ruleAssertThat(code)