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

Wrong new line check #842

Closed
kozaxinan opened this issue Aug 20, 2020 · 11 comments · Fixed by #936
Closed

Wrong new line check #842

kozaxinan opened this issue Aug 20, 2020 · 11 comments · Fixed by #936

Comments

@kozaxinan
Copy link

kozaxinan commented Aug 20, 2020

The bug you're experiencing might have already be reported!
Please search in the issues before creating one.

Expected Behavior

Method after multiline text

Observed Behavior

      """
            |longtext longtext longtext longtext longtext longtext
            |longtext longtext longtext longtext longtext longtext
            |longtext longtext longtext longtext longtext longtext
            |longtext longtext longtext longtext longtext longtext
            """.trimMargin("|")

Ktlint gives 2 error.

Argument should be on a separate line (unless all arguments can fit a single line)ktlintTestSourceSetCheck
Missing newline before ")"

Steps to Reproduce

  • Version of ktlint used: 0.38.0-alpha01
  • Name and version (or code for custom task) of integration used (Gradle plugin, Maven plugin, command line, custom Gradle task): ktlintCheck from https://github.com/JLLeitschuh/ktlint-gradle
  • Version of Gradle used (if applicable): 6.6
  • Operating System and version: MacOs - 10.15.6
  • Link to your project (if it's a public repository):
@shashachu shashachu added the bug label Aug 20, 2020
@shashachu shashachu added this to the 0.38.0 milestone Aug 20, 2020
@shashachu
Copy link
Contributor

Thanks for the report @kozaxinan. To clarify: both errors are reporting on the """.trimMargin("|") line? And can you also confirm that this is a regression with the 0.38.0 alpha? (i.e. didn't occur in 0.37.2).

@shashachu
Copy link
Contributor

Likely introduced by this commit a94b43f

@kozaxinan
Copy link
Author

kozaxinan commented Aug 20, 2020

Yes that is a regression in alpha and yes it is on trimIndent line.

@Tapchicoma
Copy link
Collaborator

@kozaxinan I could not reproduce it with following Kotlin file:

val test =
"""
            |longtext longtext longtext longtext longtext longtext
            |longtext longtext longtext longtext longtext longtext
            |longtext longtext longtext longtext longtext longtext
            |longtext longtext longtext longtext longtext longtext
            """.trimMargin("|")

Maybe you could provide full Kotlin file or link to it?

@Tapchicoma Tapchicoma modified the milestones: 0.38.0, 0.39.0 Aug 21, 2020
@kozaxinan
Copy link
Author

class Test {

  fun someMethod(str: String) = Unit

  val someString = someMethod(
    """
    longtext longtext longtext longtext longtext longtext longtext longtext
    longtext longtext longtext longtext longtext longtext longtext longtext
    longtext longtext longtext longtext longtext longtext longtext longtext
    longtext longtext longtext longtext longtext longtext longtext longtext
    longtext longtext longtext longtext longtext longtext longtext longtext
    """.trimIndent('|')
  )
}

Running ktlint on this file gives two errors.

/Test.kt:14:20: Argument should be on a separate line (unless all arguments can fit a single line)
/Test.kt:14:23: Missing newline before ")"

@Tapchicoma
Copy link
Collaborator

@kozaxinan sorry, but you example only produces indentation errors for me with latest build from master:

Test.kt:3:1: Unexpected indentation (2) (should be 4)
Test.kt:5:1: Unexpected indentation (2) (should be 4)
Test.kt:6:1: Unexpected indentation (4) (should be 8)
Test.kt:6:5: Unexpected indentation (expected 6, actual 4)
Test.kt:13:1: Unexpected indentation (2) (should be 4)

Could you try 0.38.0 release?

@kozaxinan
Copy link
Author

I tested that code example with 0.38 and command line ktlint.

I will test issue in a fresh repo.

@Tapchicoma
Copy link
Collaborator

Do you have .editorconfig in your repo? Could you paste content of it here? It may affect ktlint results.

@kozaxinan
Copy link
Author

I checked code in empty folder outside of project without editorconfig.

Running 'ktlint --android' gives errors for me with 0.38

@Tapchicoma
Copy link
Collaborator

Yeah, with --android I could also reproduce it 👍

@Tapchicoma
Copy link
Collaborator

@kozaxinan with 0.39.0 release you could disable experimental 'argument-list-wrapping' rule to suppress this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants