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

Missing newline after namedParameter="""string""" #898

Closed
ZakTaccardi opened this issue Sep 10, 2020 · 3 comments
Closed

Missing newline after namedParameter="""string""" #898

ZakTaccardi opened this issue Sep 10, 2020 · 3 comments
Labels

Comments

@ZakTaccardi
Copy link

ZakTaccardi commented Sep 10, 2020

Expected Behavior

I expect the following to pass formatting.

json(jsonString = """{ "id": "1234" }""")

Observed Behavior

Fails with: Missing newline after "=" (indent)

Steps to Reproduce

fun json(jsonString: String?) {
    TODO()
}

fun exampleThatFailsKtLint() {
    json(jsonString = """{ "id": "1234" }""")
}

fun exampleThatPassesKtLint() {
    // Android Studio formatting will move this back to next example, which will fail ktlint
    json(
        jsonString =
            """{ "id": "1234" }"""
    )
}

fun exampleThatFailsKtLintWhichAndroidStudioAutoFormatsTo() {
    json(
        jsonString =
        """{ "id": "1234" }"""
    )
}

fun exampleThatPassesLint() {
    // lacks named parameter
    json(
        """{ "id": "1234" }"""
    )
}
fun exampleThatPassesLint2() {
    // lacks named parameter
    json("""{ "id": "1234" }""")
}

Your Environment

  • Version of ktlint used: 0.38.1 (command line)
  • AS 4.0.1 with AGP 3.6
  • Operating System and version: MacOS 10.15.6
@ZakTaccardi
Copy link
Author

ZakTaccardi commented Sep 10, 2020

I also tried disabling this but it did not seem to work?

/* ktlint-disable indent */
json(jsonString = """{ "taskReferenceId": "1234" }""")
/* ktlint-enable indent */

I added this line.

import android.view.* // ktlint-disable no-wildcard-imports

Without the comment, I saw Wildcard import (cannot be auto-corrected) (no-wildcard-imports). After adding the comment, the error was suppressed. Seems like there is an issue with disabling the indent rule? I also checked with:

/* ktlint-disable no-wildcard-imports */
import android.view.*
/* ktlint-enable no-wildcard-imports */

Which worked as expected.

This is a separate issue probably

@Tapchicoma Tapchicoma added the bug label Sep 10, 2020
@Tapchicoma
Copy link
Collaborator

I could not reproduce your issue with build from current master. Most probably it was fixed via #711 issue.

Please open a separate issue regarding "indent" rule disabling is not working.

@Tapchicoma Tapchicoma added this to the 0.40.0 milestone Sep 10, 2020
@romtsn
Copy link
Collaborator

romtsn commented Sep 10, 2020

Yeah this is fixed already on master. Disabling the indent rule is also not possible at the moment as it runs all or nothing (only possible for the entire file), gonna be possible after we split it as mentioned in #764. Please look for the next release, we are planning to release 0.39.0 soon

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

3 participants