Skip to content

Commit

Permalink
Fix false positive in class-signature when EOL comment is between a…
Browse files Browse the repository at this point in the history
… class annotation and other class modifier (#2786)

Closes #2755
  • Loading branch information
paul-dingemans authored Sep 3, 2024
1 parent 9ba1d0c commit 60efc8f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ public class ClassSignatureRule :
currentNode = iterator.next()
if (currentNode.elementType != ANNOTATION &&
currentNode.elementType != ANNOTATION_ENTRY &&
currentNode.elementType != WHITE_SPACE
currentNode.elementType != WHITE_SPACE &&
currentNode.elementType != EOL_COMMENT
) {
return currentNode
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1849,6 +1849,20 @@ class ClassSignatureRuleTest {
classSignatureWrappingRuleAssertThat(code).hasNoLintViolations()
}

@Test
fun `Issue 2755 - Given a class preceded by an annotation, and EOL comment, and another class modifier then ignore the EOL comment in determination of class signature length`() {
val code =
"""
// $MAX_LINE_LENGTH_MARKER $EOL_CHAR
@Suppress("UnnecessaryAbstractClass") // some comment
abstract class Bar(val baz1: String, val baz2: String)
""".trimIndent()
classSignatureWrappingRuleAssertThat(code)
.setMaxLineLength()
.withEditorConfigOverride(FORCE_MULTILINE_WHEN_PARAMETER_COUNT_GREATER_OR_EQUAL_THAN_PROPERTY to "unset")
.hasNoLintViolations()
}

private companion object {
const val UNEXPECTED_SPACES = " "
const val NO_SPACE = ""
Expand Down

0 comments on commit 60efc8f

Please sign in to comment.