koppor / jabref

Collection of simple for JabRef issues. Please submit PRs to https://github.com/jabRef/jabref/.
https://github.com/jabRef/jabref/
MIT License
8 stars 14 forks source link

Switch to palantir-java-format #663

Closed koppor closed 7 months ago

koppor commented 8 months ago

I am so fed up that

Thus, I am looking for good autoformatting tools. I thought Google's Java Code Style would be great. However, 4 spaces need extra configuration. Moreover, the project seems to be unmaintained currently. Luckily, I found a maintained alternative: palantir-java-format

The diffs look good. Only three drawbacks:

For me these are no real drawbacks or show stoppers.

REgarding migration: One needs to switch away from JabRef code style to "Default". However, I think, this is manageable as the active contributors can be informed - and the "drive-by" contributors are setting up their IDE before their contribution.

image

(GJF was tried out at https://github.com/koppor/jabref/pull/661)


Open issues:

Mandatory checks

k3KAW8Pnf7mkmdSMPHz27 commented 8 months ago

My only problem with it thus far has been,

  1. they update the style a bit faster than I'd like,
  2. I mainly use Maven 😢
  3. The marketplace plugin hasn't always been compatible with the most recent IntelliJ IDEA versions

I like the look it enforces, and it has some customizability with the Checkstyle rules. I'll try setting it up for IntelliJ in Windows based on this branch.

github-actions[bot] commented 7 months ago

Your code currently does not meet JabRef's code guidelines. We use Checkstyle to identify issues. The tool reviewdog already placed comments on GitHub to indicate the places. See the tab "Files" in you PR. Please carefully follow the setup guide for the codestyle. Afterwards, please run checkstyle locally and fix the issues.

More information on code quality in JabRef is available at https://devdocs.jabref.org/getting-into-the-code/development-strategy.html.

github-actions[bot] commented 7 months ago

Your code currently does not meet JabRef's code guidelines. We use OpenRewrite to ensure "modern" Java coding practices. The issues found can be automatically fixed. Please execute the gradle task rewriteRun, check the results, commit, and push.

You can check the detailed error output at the tab "Checks", section "Tests" (on the left), subsection "OpenRewrite".

koppor commented 7 months ago

As alternative, I checked spring-java-format, but it provides bad wrapping:

     /**
-     * Add X11 clipboard support to a text input control. It is necessary to call this method in every input where you
-     * want to use it: {@code ClipBoardManager.addX11Support(TextInputControl input);}.
-     *
-     * @param input the TextInputControl (e.g., TextField, TextArea, and children) where adding this functionality.
-     * @see <a href="https://www.uninformativ.de/blog/postings/2017-04-02/0/POSTING-en.html">Short summary for X11
-     * clipboards</a>
-     * @see <a href="https://unix.stackexchange.com/questions/139191/whats-the-difference-between-primary-selection-and-clipboard-buffer/139193#139193">Longer
+     * Add X11 clipboard support to a text input control. It is necessary to call this
+     * method in every input where you want to use it:
+     * {@code ClipBoardManager.addX11Support(TextInputControl input);}.
+     * @param input the TextInputControl (e.g., TextField, TextArea, and children) where
+     * adding this functionality.
+     * @see <a href=
+     * "https://www.uninformativ.de/blog/postings/2017-04-02/0/POSTING-en.html">Short
+     * summary for X11 clipboards</a>
+     * @see <a href=
+     * "https://unix.stackexchange.com/questions/139191/whats-the-difference-between-primary-selection-and-clipboard-buffer/139193#139193">Longer
      * text over
-    public ArgumentProcessor(String[] args,
-                             Mode startupMode,
-                             PreferencesService preferencesService,
-                             FileUpdateMonitor fileUpdateMonitor,
-                             BibEntryTypesManager entryTypesManager) throws org.apache.commons.cli.ParseException {
+    public ArgumentProcessor(String[] args, Mode startupMode, PreferencesService preferencesService,
+            FileUpdateMonitor fileUpdateMonitor, BibEntryTypesManager entryTypesManager)
+            throws org.apache.commons.cli.ParseException {
koppor commented 7 months ago

Note that spring java format uses tabs, because of good reasons:

koppor commented 7 months ago

prettier-java does a great job in line wrapping.

palantir output:

        action.getKeyBinding().ifPresent(keyBinding -> keyBindingRepository
                .getKeyCombination(keyBinding)
                .ifPresent(combination -> setAccelerator(combination)));

prettier output:

        action
            .getKeyBinding()
            .ifPresent(keyBinding ->
                keyBindingRepository
                    .getKeyCombination(keyBinding)
                    .ifPresent(combination -> setAccelerator(combination))
            );

I like prettier more, because

I'll file another PR. Let's see, how it works out ^^

koppor commented 7 months ago

The prettier-java output was "random", because line wrapping was at 80 chars... If set to 100 or 120 the wrapping is worse.

koppor commented 7 months ago

Blocked by https://github.com/palantir/palantir-java-format/pull/935

koppor commented 6 months ago

Is it ehtically OK to use Palantir - even if it is "the best candidate"?

https://www.heise.de/news/Trotz-Bedenken-Bayern-testet-Palantir-Software-mit-echten-Personendaten-9545037.html

umstrittene[s] US-Unternehmen[...] Palantir