Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix false positive in class-signature when EOL comment is between a class annotation and other class modifier #2786

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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