Add better instructions for re-formatting the project#4540
Merged
jlerbsc merged 1 commit intoAug 21, 2024
Merged
Conversation
Collaborator
Author
Collaborator
|
Thank you for these clarifications |
Contributor
|
I just saw that applying spotless to my unit tests inlined lines that were intended for readability. See commit 770f766. This changed Node root = parse("package com;"
+ "import com.*;"
+ "import org.*;"
+ "abstract class Foo {}");to Node root = parse("package com;" + "import com.*;" + "import org.*;" + "abstract class Foo {}");Had I seen the change earlier, I would have changed it to Similar changes happened in commit 5106428. I couldn't find any options for palantir-java-format that could prevent this kind of inlining. Concatenating two string literals on the same line is also not done automatically. I suggest mentioning in the instructions to check the changes after applying spotless. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The style check I've added has caused some confusion for 2 reasons:
Specifically, I mentioned in the original spotless PR that the check that is run first runs the code generators, then runs spotless. In later comments and in
CONTRIBUTING.md, however, I said that running./mvnw spotless:applywould fix style errors. This was not correct and I did not consider that the code generators would introduce style changes that wouldn't be "fixed" by spotless.There have been a few cases where the generators have made whitespace changes that weren't changed by spotless, however, and the instructions I gave also don't give any guidance in cases where there are legitimate codegen issues (for example if someone implemented a method manually when it should've been generated), so I've updated the instructions in
CONTRIBUTING.mdto be much more clear (and correct) about what's required.I also mentioned creating a custom maven command (for example
./mvnw format) to make this process simpler for contributors, but this would only work on systems withbashavailable and isn't much simpler than running the code generators in any case. I think just having better instructions available is a better solution.