-
Notifications
You must be signed in to change notification settings - Fork 114
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
Change formatter plugin to @diffplug's Spotless plugin (Attempt 2) #214
Conversation
Advantages of Spotless over current solution: - Error messages are (in my opinion) easier to understand. - We can easily adopt other formatters in the future, such as a formatter which checks that files have license headers that follow a certain template.
Hmm. To say that this is slightly maddening would IMO be an understatement. For some reason, the Spotless plugin for Maven continues to report that the checked-out code has @jrtom @nedtwigg @lutovich I wonder if y'all have any ideas as to what may be causing this, and/or how we may work around it? |
Note to self: try checking out the code for this PR and running |
Two responses, off the top of my head: (1) Is there any way to configure Spotless so that it doesn't care about line endings? |
I think it's happening due to google-java-format, which Spotless calls. The latest google-java-format version, 1.6, enforces that all comments be at most n characters long (I think 100) and that there is a space between the start of a comment and the first word in that comment. I could downgrade to 1.4 or 1.5 (whichever one is the last version that doesn't have this new rule) if you wish. :)
I'll investigate! |
Line wraps: It looks like the comment-line-length enforcement has been there since 1.4, and we're currently using 1.3, so that would explain it: https://github.com/google/google-java-format/releases (That said, if there's any convenient way of separating the migration from 1.3 to 1.6 from the migration to use spotless, I'd advise doing that; it will make the reviews simpler.) |
Yep, I think there is. I'll focus on Spotless in this PR, then, and if I remember to do so, I'll upgrade google-java-format in a separate PR. |
Thanks. Filed #215 for the google-java-format upgrade. |
The google-java-format upgrade has been reverted. I'll investigate whether I can ignore line endings with Spotless next. |
…h newlines properly on Travis CI See the following link for more information: https://github.com/diffplug/spotless/tree/master/plugin-maven#line-endings-and-encodings-invisible-stuff
…mit didn't convince Travis to behave
So maybe I'm missing something, but looking at the errors on Travis, it looks like there's a relatively small number of files that are being flagged as having /r/n instead of just /n. It looks like they were among the most recently added files. (And I would expect to see others among the visualization code.) So I'd guess that it's just something about an editor that Tom was using. What if you just let Spotless fix them? It would be nice if we didn't have an inconsistency in the line ending characters in the repo, and it's arguably better than hacking Spotless to not care about the distinction. |
It may be that one of your committers has https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration It looks to me like spotless is probably behaving correctly here. |
@jrtom I remember trying that some time ago with no success, but I can't really remember what the difficulty was. I'll try manually changing the files on my machine and see if committing them afterwards fixes the problem.
On both my Windows and Linux machines, Spotless runs perfectly fine - it doesn't report any errors - so I think I'll need to manually adjust line endings. |
@nedtwigg Thanks for the suggestion! I've just confirmed on my Windows machine that my installation of Git is |
@jbduncan if you just apply Spotless locally (as the error is asking) does that do anything?
(If it does, that's kind of interesting that it would ignore them on your machine but not on Travis.) |
Oh, I figured out why my Linux VM wasn't reported any errors - it was because I forgot to On my Windows machine, running Might the end be in sight? :) I'll report back when I know more. |
…y` on my Ubuntu VM
Do my eyes deceive me? I do believe Travis is passing, now. 🎉 |
In other words, @jrtom, I'm ready to continue reviewing and merge whenever you're ready. |
If at first you don't succeed, try a bigger hammer. My one remaining question is: why did you have to check out |
It's because I just ran I... can't remember what it was I was doing that meant that Maven didn't complain about it sooner. Sorry! |
*.txt text | ||
|
||
# Known binary files | ||
*.jar binary |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing newline at EOF
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch! Done.
Oh, never mind, I just got confused, you said Thanks for getting this sorted out. At some point we might want to see whether it is possible for spotless to automatically change the line-ending characters rather than asking the user to do it explicitly, but I'm not 100% convinced that that's the right answer. |
I'm not 100% convinced either. Would that mean that each time Travis CI sees a new commit, it would have to create a new automatic commit with the result of |
I don't mind the git log getting cluttered--I've moved to squash-and-merge anyway for PRs--but you're right that we don't want Travis making these changes. What I'd prefer is that there be something integrated into git push on the client side that would reject a push if the tests or formatting checks failed. But I'm used to coding in an environment in which that's a fact of life. shrug Anyway, this is a separate discussion and should not block merging your PR, so without further ado... :) |
pre-commit might be very useful for this! But yeah, I'll open that as a new issue to discuss. :) Cheers! 🎉 |
I'm running into a problem building with Maven since this change; any idea what's going on? This is the result of running
|
Just realized I still have old versions of Maven installed. Build still passes when I downgrade to Maven 3.1.1, but fails with Maven 3.0.5. So that's it indeed :) |
Yes, I think @Stephan202 is right. It's not obvious, but according to the Spotless Maven plugin README, at least Maven 3.1.0 is required. :) But if you're using a compatible version of Maven, and if it doesn't work still even if you upgrade to the latest version, then it's not immediately obvious to me what the problem would be... |
Since |
@Stephan202 thanks. Installing Maven 3.5.4 seems to have done the trick. Problem solved. @nedtwigg Oddly enough, that error didn't appear with 3.0.4 (which is what I had) + Spotless 1.14. |
Thanks for letting us know that the proactive warn isn't working. Making the error proactive is tricky - it's a race between us and maven, who throws their error first, and looks like Maven is winning. Maven 3.1.0 was released on 2013-07-15, so it's not ancient, but it's not that recent either. Unlikely that this will make it to the top of anyone's todo list, but I'll let @lutovich know just in case. |
Spotless Maven plugin has a bug and Maven version prerequisite is not included in the correct POM. I've only tested this prerequisite manually by editing the plugin's POM and forgot that final POM for Maven Central is generated. Sorry about this, hope you did not lose too much time on it :) This PR should be the fix diffplug/spotless#289 and make error messages nicer. |
This is a follow-on to #198 to attempt to get get things working again on Travis CI.