8000 Add better instructions for re-formatting the project by johannescoetzee · Pull Request #4540 · javaparser/javaparser · GitHub
[go: up one dir, main page]

Skip to content

Conversation

johannescoetzee
Copy link
Contributor

The style check I've added has caused some confusion for 2 reasons:

  1. What I've explicitly communicated so far is not consistent with what's actually being checked
  2. The instructions I added to CONTRIBUTING.md are not sufficient to guarantee that a change will pass the style check.

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:apply would 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.md to 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 with bash available and isn't much simpler than running the code generators in any case. I think just having better instructions available is a better solution.

@johannescoetzee
Copy link
Contributor Author

I hope this addresses any confusion caused, for example in #4538 and #4527 (where I was caught by the same issue)

@jlerbsc jlerbsc merged commit b267ed7 into javaparser:master Aug 21, 2024
@jlerbsc
Copy link
Collaborator
jlerbsc commented Aug 21, 2024

Thank you for these clarifications

@jlerbsc jlerbsc added this to the next release milestone Aug 21, 2024
@ktul
Copy link
Contributor
ktul commented Aug 23, 2024

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

Node root = parse("package com; import com.*; import org.*; abstract class Foo {}");

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

0