pinterest / ktlint

An anti-bikeshedding Kotlin linter with built-in formatter
https://pinterest.github.io/ktlint/
MIT License
6.23k stars 512 forks source link

How to enable disabled MultiLineIfElseRule rule? #521

Closed Lingviston closed 5 years ago

Lingviston commented 5 years ago

Hi This rule is disabled via .editorconfig but I want to use it. How can I enable it back? I tried creating my own .editorconfig and declaring disabled_rules=unset there but it didn't help.

shashachu commented 5 years ago

The new editorconfig support is not released yet. That said, I realized yesterday that I actually need to go back to disabling rules via commenting them out, because the .editorconfig only applies to ktlint itself.

The MultiLineIfElseRule specifically is disabled right now because it just doesn't work well. I also discovered yesterday that having it enabled can make the IndentRule fail.

If you'd like to enable it for your own project, you will need to copy it in via a custom ruleset. See the README here: https://github.com/pinterest/ktlint#creating-a-ruleset

Lingviston commented 5 years ago

@shashachu Thanks for the response. Already did it through the custom ruleset but was looking for the more convenient way. Can you provide some code snippets, which are not processed properly by that rule? I saw one in comments but it was mentioned that it can't be properly auto-corrected. I personally don't need auto-correct feature, so I only wonder if it doesn't detekt violation properly in some cases.

shashachu commented 5 years ago

@shashachu Thanks for the response. Already did it through the custom ruleset but was looking for the more convenient way. Can you provide some code snippets, which are not processed properly by that rule? I saw one in comments but it was mentioned that it can't be properly auto-corrected. I personally don't need auto-correct feature, so I only wonder if it doesn't detekt violation properly in some cases.

As far as I know, it's only the auto-correct that isn't working.