-
Notifications
You must be signed in to change notification settings - Fork 504
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
argument-list-wrapping stops working with too many arguments #2461
Comments
Yes, I am aware of that (see https://github.com/pinterest/ktlint/blob/master/ktlint-ruleset-standard/src/main/kotlin/com/pinterest/ktlint/ruleset/standard/rules/ArgumentListWrappingRule.kt#L115). It has been added in this commit by another maintainer (I did not yet joined the project then). Unfortunately, there is no rationale documented for it. Simply removing it, may lead to complaints of other users that rely on it. It has been added in ktlint |
This seems rather random. Would it be possible to add a configuration instead and default it to 8? |
Yes it is. But I think I have found the reason why it was added without an issue. Ktlint contains quite a few statements like below:
So most likely while running the rules on the own code base, it turned out that this would to huge code blocks if each element would be wrapped to a separate line.
Yes, technically not a problem. But as said, this random number has now been here for over 3 years and you're the first who wants it get changed. Each configuration setting can lead to more discussion between team members about what the best value is. What would your ideal value be, and more importantly why specific that value? |
Adding the property would be for legacy/backwards compatibility reason, addressing your comment it cannot simply be removed. My preference would be to remove that 8. If a new configuration gets added for it, I would set it to 0/unset to always wrap when |
Lol, this is probably the only valid argument for this configuration setting. And in case of a list of arguments which get to long, the rule can always be suppressed for that statement:
Let me consider whether I will set the default for |
The would definitely be enough for me. I'm only interested in auto-formatting when there are more than 8 arguments. |
… treshold of parameters Breaking change: For code style `ktlint_official` the default value for this setting has default `unset` which is different from previous default value `8`. Not wrapping parameters should be a conscious decision of the developer. This can either be done on a case by case basis by suppressing the rule, or by configuring the parameter. Closes #2461
… treshold of parameters (#2481) * Add configuration setting for ignoring `argument-list-wrapping` above treshold of parameters Breaking change: For code style `ktlint_official` the default value for this setting has default `unset` which is different from previous default value `8`. Not wrapping parameters should be a conscious decision of the developer. This can either be done on a case by case basis by suppressing the rule, or by configuring the parameter. Closes #2461
argument-list-wrapping
doesn't work for 9 or more arguments.It's arguable if a function should have that many parameters, but the same is also failing for constructor calls (e.g.. data classes).
Expected Behavior
Observed Behavior
The example above fails. Below works though.
Your Environment
master
as well)The text was updated successfully, but these errors were encountered: