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

Analyse and resolve bugs found while rewriting tests #1456

Closed
paul-dingemans opened this issue Apr 25, 2022 · 0 comments · Fixed by #1862
Closed

Analyse and resolve bugs found while rewriting tests #1456

paul-dingemans opened this issue Apr 25, 2022 · 0 comments · Fixed by #1862
Labels
Milestone

Comments

@paul-dingemans
Copy link
Collaborator

During rewrite of tests (#1444) to using the KtLintAssertThat API, I encounted a number of situations in which a rule does seem to contain a bug. Most of them are simple off-by-one mistakes in the offset at which an error is found. Those situations can easily be found by searching for TODO and @Disabled in the unit tests of the KtLint rules.

Examples:

annotationRuleAssertThat(code)
    // TODO: Offset and message is not entirely clear
    .hasLintViolation(
        2,
        5,
        "Annotations with parameters should all be placed on separate lines prior to the annotated construct"
    )
    .isFormattedAs(formattedCode)

and

@Disabled("To be implemented")
@Test
fun `Given a semi colon at the start of a line then do report a lint error`() {
    val code =
        """
        ;val fooBar = "fooBar"
        """.trimIndent()
    val formattedCode =
        """
        val fooBar = "fooBar"
        """.trimIndent()
    noSemicolonsRuleAssertThat(code)
        .hasLintViolation(1, 1, "Unnecessary semicolon")
        .isFormattedAs(formattedCode)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant