-
Notifications
You must be signed in to change notification settings - Fork 506
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
Allow to disable rules globally #32
Comments
I am not sure if it matches the project's ideology, which is against configuration. But if we finally decided to introduce configuration, I would recommend looking at how it is done in ESLint http://eslint.org/docs/user-guide/configuring and introducing |
Personally I don't need a configuration right now, but rather a mechanism to disable certain rules globally and a finer-grained set of rules. Command-line parameter would be sufficient and I think it's a pretty good compromise. A benefit of using a configuration is that it can be easily copied to a different project and you don't lock yourself to a particular library. |
@dstarcev is right, any form of configuration (cli parameter included) is against project's ideology. The reasons are the same as for standardjs - http://standardjs.com/#faq ("I disagree with rule X, can you change it?" section). @inikolaev can you please elaborate which rules are giving you a hard time (and in what way)? What exactly do you mean by "I need it [indentation rule] to behave differently in different contexts"? If rule is misbehaving - it can always be fixed. |
Well one of my use cases is method/constructor parameter lists: when there's a long list of parameters we want to be able to write it in the following way: data class A(val a: Any,
val b: Any,
val c: Any)
class B(val a: Any,
val b: Any,
val c: Any) {
}
fun doSomething(val a: Any,
val b: Any,
val c: Any) {
} Right now I'm getting error:
So if I understand correctly, this linter doesn't allow any kind of customisation by design? |
Take a look at #26 (comment) (the whole ticket is basically about the same thing) (related discussion - Kotlin/kotlin-style-guide#15). Now, considering that this is not the first time this particular case is brought up and the fact that it creates way too much contention we might make an exception here and update IndentationRule.kt to allow vertical alignment of parameters. What do you think?
Yes, this is intentional. |
Maybe if you stick to some particular way of vertical alignment you should provide a bit more detailed message about how it should be fixed.
|
@inikolaev fair enough. I'll see what I can do. Thank you! |
@inikolaev I've added a little bit of context to the error messages, relaxed indent rule to accept both fun f(
val a: Any,
val b: Any,
val c: Any
) {
} and fun f(val a: Any,
val b: Any,
val c: Any) {
} as valid and released ktlint@0.5.0 (here are the release notes). Feel free to reopen the ticket if there is still a need for it. |
I would like to have a command line parameter which would allow to disable certain rules so that I don't have to add comments to each file in a project.
Right now it looks like the only way to do that is to add a comment to each file where I need to disable a check, which is a bit intrusive I think.
One example is I would like to disable indentation rule, because I need it to behave differently in different contexts and ideally I would need to have different rules for different context which could be enabled/disabled.
The text was updated successfully, but these errors were encountered: