Skip to content
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

Use Prettier Java for automatic code formatting #10646

Closed
wants to merge 27 commits into from

Conversation

koppor
Copy link
Member

@koppor koppor commented Nov 17, 2023

Background

I am so fed up that

I checked multiple formats and tools (palantir-java-format (JabRef#663), spring-java-format, google-java-format, spotless, square java style) - and "Prettier Java" seems to be best

I focus in *.java. XML could come next.

Changed

  • Reformatter WITH COMMIT in the CI
  • Howto refined

Notes

When coming from a fork, this action will just fail.

See https://github.com/orgs/community/discussions/75867 for details.

I had to disable the OpenRewrite rule UnnecessaryParentheses - see openrewrite/rewrite-static-analysis#219 for details

Next steps

Better comments

The commenting action cannot comment on pull requests, but @reviewdog can. I removed the commenting things here. Follow-up is to convert the output in case of errors to a format consumable to reviewdog.

Negleted by the team

I would like to switch from spaces to tabs:

- tabWidth: 4
+ useTabs: true

Mandatory checks

  • Change in CHANGELOG.md described in a way that is understandable for the average user (if applicable)
  • Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • Screenshots added in PR description (for UI changes)
  • Checked developer's documentation: Is the information available and up to date? If not, I outlined it in this pull request.
  • Checked documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request to the documentation repository.

@koppor koppor marked this pull request as draft November 17, 2023 13:07
@Siedlerchr
Copy link
Member

No, please keep spaces! Even though they might be better suited for some people this will mess up everything else

@calixtus
Copy link
Member

+1 for keeping spaces. Modern braille displays should be able to deal with multiple whitespaces. If we change this, almost every line of code will be changed and the whole git history and blame will only show one name. Even though you can go back in history with some commands, it won't be shown directly and will destroy the very overlook on the blame.

@Siedlerchr
Copy link
Member

It seems to still break at 80 chars width or at least introduces a lot of unnecessarily wrapping

@tobiasdiez
Copy link
Member

+1 for keeping spaces. Modern braille displays should be able to deal with multiple whitespaces. If we change this, almost every line of code will be changed and the whole git history and blame will only show one name. Even though you can go back in history with some commands, it won't be shown directly and will destroy the very overlook on the blame.

That can be easily fixed with .git-blame-ignore-revs (which should be used anyway for large reformatting changes such as this PR)

@koppor
Copy link
Member Author

koppor commented Nov 18, 2023

It seems to still break at 80 chars width or at least introduces a lot of unnecessarily wrapping

OMG. - Because they rely on prettier, this is configurable. I switched from palantir, which has 120 characters, but a "review-friendly" wrapping - https://github.com/palantir/palantir-java-format#motivation--examples.

I changed to 100 chars.

But that is no "review-friendly" line wrapping. Code less readable IMHO. Thus, I am closing this one and go back to try out palantir.

@koppor koppor closed this Nov 18, 2023
@koppor koppor deleted the switch-to-prettier branch November 18, 2023 11:39
@koppor koppor restored the switch-to-prettier branch November 18, 2023 11:40
@koppor koppor deleted the switch-to-prettier branch November 18, 2023 11:40
@koppor koppor mentioned this pull request Jan 10, 2024
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants