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
then ktlint 0.50.0 is not able to format this in 3 consecutive runs.
After the first iteration, the code is transformed to:
class EnhanceStackTraceWithTreadDumpAsJsonTest : DebugTestBase() {
@Test
fun testEnhancedStackTraceFormatWithDeferred() =
runTest {
val enhancedStackTraceFromJson = Gson().fromJson(enhancedStackTraceAsJsonString, Array<StackTraceElementInfoFromJson>::class.java)
}
}
But now line 5 is exceeding the max-line-length (defaulted to 140). After fixing this in the second iteration, the code is transformed to:
class EnhanceStackTraceWithTreadDumpAsJsonTest : DebugTestBase() {
@Test
fun testEnhancedStackTraceFormatWithDeferred() =
runTest {
val enhancedStackTraceFromJson = Gson().fromJson(
enhancedStackTraceAsJsonString,
Array<StackTraceElementInfoFromJson>::class.java
)
}
}
Next problem is that the multiline expression, starting at line 5, is wrapped in the third iteration. The code is transformed to:
class EnhanceStackTraceWithTreadDumpAsJsonTest : DebugTestBase() {
@Test
fun testEnhancedStackTraceFormatWithDeferred() =
runTest {
val enhancedStackTraceFromJson =
Gson().fromJson(
enhancedStackTraceAsJsonString,
Array<StackTraceElementInfoFromJson>::class.java
)
}
}
And finally the last problem (a missing trailing comma at line 8 is identified) which is fixed in the fourth iteration:
class EnhanceStackTraceWithTreadDumpAsJsonTest : DebugTestBase() {
@Test
fun testEnhancedStackTraceFormatWithDeferred() =
runTest {
val enhancedStackTraceFromJson =
Gson().fromJson(
enhancedStackTraceAsJsonString,
Array<StackTraceElementInfoFromJson>::class.java,
)
}
}
Because of the order in which the rules are executed, it is sometimes needed to iterate multiple times. Setting this number too high has consequences for total througput time in case an accidental endless loop is triggered (for example see #2128).
Options:
Increase maximum number of consecutive runs to 5
make the maximum number of consecutive runs configurable with current default of 3
accept that occasionally multiple manual incovations are needed to fix all problems
The text was updated successfully, but these errors were encountered:
…ich (theoretically) can be autocorrected in file ... in 3 consecutive runs of format` only when after the third consecutive run still a violation exists that can be autocorrected.
Closes#2129
Given code below:
and
.editorconfig
:then ktlint
0.50.0
is not able to format this in 3 consecutive runs.After the first iteration, the code is transformed to:
But now line 5 is exceeding the max-line-length (defaulted to 140). After fixing this in the second iteration, the code is transformed to:
Next problem is that the multiline expression, starting at line 5, is wrapped in the third iteration. The code is transformed to:
And finally the last problem (a missing trailing comma at line 8 is identified) which is fixed in the fourth iteration:
Because of the order in which the rules are executed, it is sometimes needed to iterate multiple times. Setting this number too high has consequences for total througput time in case an accidental endless loop is triggered (for example see #2128).
Options:
The text was updated successfully, but these errors were encountered: