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

Supressing a error is not working #158

Closed
Tapchicoma opened this issue Feb 23, 2018 · 10 comments
Closed

Supressing a error is not working #158

Tapchicoma opened this issue Feb 23, 2018 · 10 comments

Comments

@Tapchicoma
Copy link
Collaborator

I am trying to suppress max-line-length error, but it is not working.

What I've tried so far:

  • adding // ktlint-disable max-line-length in the end of failing line
  • adding // ktlint-disable in the end of failing line
  • adding /* ktlint-disable */ before failing line and /* ktlint-enable */ after failing line

Ktlint version 1.15.0

@Tapchicoma
Copy link
Collaborator Author

Ktlint version 1.15.1 has the same problem.

@Tapchicoma
Copy link
Collaborator Author

Happens only when project has .editorconfig with redefined max-line-length

@shyiko
Copy link
Collaborator

shyiko commented Feb 27, 2018

(Hopefully) Fixed in 0.16.0.

@shyiko shyiko closed this as completed Feb 27, 2018
@Zayankovsky
Copy link

Adding // ktlint-disable max-line-length in the end of failing line still does not suppress max-line-length error
Only adding /* ktlint-disable max-line-length */ before failing line and /* ktlint-enable max-line-length */ after failing line works
Ktlint version 0.29.0

@shyiko shyiko reopened this Feb 4, 2019
@shyiko
Copy link
Collaborator

shyiko commented Feb 12, 2019

@Zayankovsky any chance you can provide an example? I'm unable to reproduce.

@shyiko shyiko closed this as completed Feb 12, 2019
@Zayankovsky
Copy link

Zayankovsky commented Feb 12, 2019

This is my .editorconfig:

[*.{kt,kts}]
insert_final_newline=true
max_line_length=120

This class triggers max-line-length error, despite the suppression:

class Whatever {

    private fun whatever(whatever: Any) = whatever

    private val whatever = whatever(whatever(whatever(whatever(whatever(whatever(whatever(whatever(whatever("whatever"))))))))) // ktlint-disable max-line-length
}

This class does not trigger max-line-length error:

class Whatever {

    private fun whatever(whatever: Any) = whatever

    /* ktlint-disable max-line-length */
    private val whatever = whatever(whatever(whatever(whatever(whatever(whatever(whatever(whatever(whatever("whatever")))))))))
    /* ktlint-enable max-line-length */
}

Ktlint version 0.30.0

@shyiko
Copy link
Collaborator

shyiko commented Feb 13, 2019

Thank you, @Zayankovsky! Fixed.

@westy92
Copy link

westy92 commented Aug 1, 2023

You can also use @Suppress("ktlint:standard:max-line-length")

https://pinterest.github.io/ktlint/0.49.1/faq/#how-do-i-suppress-errors-for-a-lineblockfile

@kenyee
Copy link

kenyee commented Sep 19, 2023

For some reason, I had to use @Suppress("ktlint:max-line-length") so it wouldn't get flagged via command line ktlint.
IDE ktlint is fine w/o the "ktlint:" prefix. Both are roughly on the same version 0.46/0.48.

@paul-dingemans
Copy link
Collaborator

Please read docs and suppress "ktlint:standard:max-line-length"

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

No branches or pull requests

6 participants