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
Given a long function name (as found in test cases for example) with an expression body and no parameters:
fun`a very long function name as found in a test case`() ="some-result"
The function name here exceeds the maxLineLength of the FunctionSignatureRule but not the overal MaxLineLength.
Expected Behavior
To accept this formatting as breaking down into multiline function signature will not fix the problem.
Observed Behavior
Ktlint will assume there are parameters and we will go into multiline mode. Suggesting to put the expression on the same line as the function signature.
Steps to Reproduce
Unit testcase is included in the following PR: #1774
Your Environment
Version of ktlint used: 0.47.1
.editorconfig not used
Name and version (or code for custom task) of integration used (Gradle plugin, Maven plugin, command line, custom Gradle task): detekt formatting plugin 1.22
Version of Gradle used (if applicable): 7.6
Operating System and version: Fedora 37 - Linux
The text was updated successfully, but these errors were encountered:
jtietema
pushed a commit
to jtietema/ktlint
that referenced
this issue
Jan 12, 2023
I have added a test case in the PR #1774 which demonstrates the issue. If you have a function with:
a very long name that runs past the maxLineLength
has no arguments
has a short expression body
The ktlint rule will incorrectly calculate the remaining space as it will assume the ) = will be on its own line. Resulting in a remaing space of maxLineLength - ") =".length when in reality it is a single line (as we don't have parameters to wrap) so the remaining space should be 0 (at least, that is what I think it should be 😅).
Given a long function name (as found in test cases for example) with an expression body and no parameters:
The function name here exceeds the
maxLineLength
of theFunctionSignatureRule
but not the overalMaxLineLength
.Expected Behavior
To accept this formatting as breaking down into multiline function signature will not fix the problem.
Observed Behavior
Ktlint will assume there are parameters and we will go into multiline mode. Suggesting to put the expression on the same line as the function signature.
Steps to Reproduce
Unit testcase is included in the following PR: #1774
Your Environment
.editorconfig
not usedThe text was updated successfully, but these errors were encountered: