-
Notifications
You must be signed in to change notification settings - Fork 458
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
Using paddedCell, spotless is not idempotent (check passed but apply is not a noop) #338
Comments
Can you post an absolute link to a failed commit? I cloned https://github.com/kennknowles/beam and checked out |
Closing due to inactivity. Happy to reopen with a reproducible testcase :) |
Try d05da8cf3dd74b2e5496ca85c10f0965c68cadf5. I just repro'd on a mac. Just clone, check out that commit and |
Hmm, very interesting. I just checkout that commit. |
Sure thing. Btw I think due to gradle cache it doesn't repro after the first time. I rm'd The diff touches 215 files so I'll just give a few of them:
|
Aha! I've got it reproducing now also. Here are my observations:
It seems that check/apply is kind of self-consistent, but it shouldn't matter which is called first. Thanks very much for this important bug, it is certain to unmask something interesting. I haven't dug into the code yet, but here's my guess: one of the ways a formatter can fail at idempotence is a cycle. e.g. a line is too short, so it rewraps long. Now the line is too long, so it rewraps short. In this case, PaddedCell has to make an arbitrary decision as to what the "canonical" form ought to be. We make this decision like this: spotless/lib/src/main/java/com/diffplug/spotless/PaddedCell.java Lines 155 to 157 in 5bd3885
I'm guessing that somehow this isn't doing what we expect, so that the cycle's canonical form depends on where the file's current state is in the cycle when we first look at it. I don't see how that could be the case, but that's my best guess. Not sure if I'll have time to fix this for our next release, but we'll definitely fix it. |
Fixed in |
Nice! Thanks! |
On apache/beam#7505
./gradlew spotlessCheck
passed (you can see it in the Jenkins statuses) but./gradlew spotlessApply
is not a noop, we discovered afterwards.I confirmed that with paddedCell disabled
spotlessCheck
failed.Gradle version: 4.10.3
Spotless plugin version: 3.16.0
GoogleJavaFormat: 1.7
Operating system & version: various Mac & Linux
Configuration block (also easy to see in the PR):
Errors emitted: none
If you are submitting a bug, please include the following:
gradlew spotless[Apply/Check] --stacktrace
If you're just submitting a feature request or question, no need for the above.
The text was updated successfully, but these errors were encountered: