-
Notifications
You must be signed in to change notification settings - Fork 506
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
ktlint 0.42.0 reporting incorrect indentation, and format produced bad file #1189
Comments
I also have a situation where ktlint reports an unexpected indentation of 0, should be -2 (with a 2 spaces indent size). Same, worked fine in 0.41, regressed in 0.42. |
It happens something similar with parameters with lambdas: Correct:
Running
|
We see this issue a lot with non-trailing lambda parameters too, like RxJava subscribe sites userRepositoryLazy.get().getUser(userId)
.subscribeOn(Schedulers.io())
.observeOn(SlackSchedulers.immediateMainThread())
.subscribe(
{
viewHolder.destination.setMessagingChannelAsDestination(
UserUtils.getDisplayName(prefsManagerLazy.get(), it),
isDraftInThread
)
},
Observers.consumerErrorLogger()
) |
Another example in case it helps. That's what KtLint wants: @Test fun filter_returns_empty_optional_if_false() {
val optional = Optional.of("")
with(optional.filter { true }) {
assertThat(this).isEqualTo(optional)
assertThat(this.isPresent).isTrue()
}
with(optional.filter { false }) {
assertThat(this).isNotEqualTo(optional)
assertThat(this.isPresent).isFalse()
}
} |
I'm planning on a 0.42.1 release since this was a regression introduced to 0.42. |
I'm still seeing this issue widespread in 0.42.1, it's not just with delegated properties. Here's one example class SomeTest {
fun someTest() {
assertThat(someList)
.containsExactly(
0,
9L, // windows 4 to 11, plus implied windows 12 & 13
60,
2L, // windows 2 & 3
11,
1L, // window 1
14,
1L // window 0
)
}
} Which reports
It seems to happen most often with multi-line parameters to a function call that is itself already on a continuation indent |
I do agree with @ZacSweers , we have this in random compose code places. This does not seem to be fixed |
Expected Behavior
ktlint 0.42.0 should not report invalid indentation results
Observed Behavior
ktlint 0.42.0 is reporting invalid indentation results.
The invalid indentation results also cause an improperly formatted file to be produced if ran with
--format
Problem is reproducible using gradle as well as via command-line
This did not occur with version 0.41.0
Steps to Reproduce
ktlint --format
results in an incorrectly indented file (notice last variable and closing brace)Your Environment
The text was updated successfully, but these errors were encountered: