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

MultilineRawStringIndentation false positive when using tab indentation #5564

Closed
TWiStErRob opened this issue Nov 23, 2022 · 3 comments
Closed
Labels

Comments

@TWiStErRob
Copy link
Member

Same as #5429

The original test case from #5429's OP wasn't implemented in #5453:

        @Test
        fun `don't raise multiline raw strings if all have the correct indentation - tabs`() {
            val TAB = "\t"
            val code = """
                val a = 
                ${TAB}$TQ
                ${TAB}${TAB}Hello world!
                ${TAB}${TAB}How are you?
                ${TAB}$TQ.trimIndent()
            """.trimIndent()
            subject.compileAndLint(code)
            assertThat(subject.findings)
                .isEmpty()
        }

if all the indentation levels are tabs, it miscalculates the expected by 3:

LintMessageDetailsSplitter.kt:65:11: The indentation should be 13 but it is 10. [MultilineRawStringIndentation]
LintMessageDetailsSplitter.kt:70:10: The indentation should be 12 but it is 9. [MultilineRawStringIndentation]
SuppressionGenerator.kt:16:7: The indentation should be 9 but it is 6. [MultilineRawStringIndentation]

When the code is indented by tabs, it's expected to have the indentation inside the raw string as tab too, because this rule is enforcing code indentation inside a raw string, therefore it's not part of the output.

@TWiStErRob TWiStErRob added bug good first issue Issue that is easy to pickup for people that are new to the project help wanted and removed good first issue Issue that is easy to pickup for people that are new to the project labels Nov 23, 2022
@t-kameyama
Copy link
Contributor

Indent size should be 1.

        @Test
        fun `don't raise multiline raw strings if all have the correct indentation - tabs`() {
            val code = """
                val a = 
                ${TAB}$TQ
                ${TAB}${TAB}Hello world!
                ${TAB}${TAB}How are you?
                ${TAB}$TQ.trimIndent()
            """.trimIndent()
            val subject = MultilineRawStringIndentation(TestConfig(mapOf("indentSize" to 1)))
            subject.compileAndLint(code)
            assertThat(subject.findings)
                .isEmpty()
        }

@TWiStErRob
Copy link
Member Author

Oooh, nice! Thank you, will try it.

@TWiStErRob
Copy link
Member Author

Works as advertised, TWiStErRob/net.twisterrob.gradle@79ffdd6

So this is not a false positive, just a non-conventional setup.

@TWiStErRob TWiStErRob closed this as not planned Won't fix, can't repro, duplicate, stale Nov 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants