You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When formatting with KtLint, it enforces to put operators like && or || on the previous line.
Before KtLintFormat:
which gives this error:
And gets restructured to
When running KtLint Format.
However, the official style guide for Kotlin does not indicate that multi-line conditions should be structured this way. It only states:
If the condition of an if or when statement is multiline, always use curly braces around the body of the statement. Indent each subsequent line of the condition by four spaces relative to statement begin. Put the closing parentheses of the condition together with the opening curly brace on a separate line: (from KotlinLang)
Although the attached codeBlock does put the operators on the previous line, it does not state whether operators should be on the previous or next line to conform to code style. Why does KtLint choose to format this way?
If I would want to enforce putting operators on the next line, would this be possible with KtLint?
The text was updated successfully, but these errors were encountered:
Please check #163 (comment) and all related links. In short: none of the styleguides strictly define how to wrap binary operators and we intentionally decided to break after all of them to avoid ambiguity. There's no way to invert behavior of the existing rule, so you have two options: either create your custom rule or disable the chain-wrapping rule
Hey,
When formatting with KtLint, it enforces to put operators like
&&
or||
on the previous line.Before KtLintFormat:

which gives this error:

And gets restructured to
When running KtLint Format.
However, the official style guide for Kotlin does not indicate that multi-line conditions should be structured this way. It only states:
If the condition of an if or when statement is multiline, always use curly braces around the body of the statement. Indent each subsequent line of the condition by four spaces relative to statement begin. Put the closing parentheses of the condition together with the opening curly brace on a separate line:
(from KotlinLang)Although the attached codeBlock does put the operators on the previous line, it does not state whether operators should be on the previous or next line to conform to code style. Why does KtLint choose to format this way?
If I would want to enforce putting operators on the next line, would this be possible with KtLint?
The text was updated successfully, but these errors were encountered: