-
Notifications
You must be signed in to change notification settings - Fork 507
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
Make ktlint follow @Suppress/@SuppressWarning annotations #765
Labels
Milestone
Comments
Let me think how to do it properly and come back to you. |
Hey @Tapchicoma did you have so spare time to think about this ? |
+1 |
paul-dingemans
pushed a commit
to paul-dingemans/ktlint
that referenced
this issue
May 8, 2022
…refixed by `ktlint:`. Standard rules can be suppressed using `@Suppress("ktlint:max-line-length")` while non-standard rules need to be suppressed with `@Suppress("ktlint:experimental:trailing-comma")` Also allow to use `@Suppress("ktlint")` to suppress all rules. Closes pinterest#765 Closes pinterest#1458
5 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I just read #263 thinking it would also provide a way to use
@Suppress
/@SuppressWarning
for the other rules but it's only forRemoveCurlyBracesFromTemplate
.I was going to make a PR to fix the issue but I'd like to discuss possible implementations.
Currently
Annotations are read and the rule name inside is then mapped to the ktlint rule-name.
(
RemoveCurlyBracesFromTemplate
is the rule name from Jetbrains Kotlin code inspections for Intellij)ktlint/ktlint-core/src/main/kotlin/com/pinterest/ktlint/core/KtLint.kt
Lines 482 to 518 in 3a87624
To support other rules
In the second case, we could either keep the
suppressAnnotationRuleMap
and just add every rule inside of it, which is not SOLID since every time a rule is added, this map needs to change and it's not really the concern ofKtlint
object to know it's rules' name...The other solution would be to add an attribute
suppressRuleName
toRule
so that every rule will have it's own.The argument of using
@Suppress
along with Kotlin code inspections name would be to have both your favorite editor and ktlint inspection support it.The text was updated successfully, but these errors were encountered: