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 code style to Google's Java Code Style #661

Closed koppor closed 8 months ago

koppor commented 8 months ago

I am so fed up that

Thus, I am looking for good autoformatting tools. The most prominent tool with style guide is Google's:

This PR adds it.

Let's hope for the best that the reformatting action a) really adds a new commit and b) the contributors will be able to pull these changes 😅🙈

I am aware, that there is no maintained gradle plugin.

I am also aware, that Eclipse AOSP since 5 years (https://github.com/google/google-java-format/pull/251), but maybe, this will be resolved.


Blockers

Mandatory checks

github-actions[bot] commented 8 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.

Siedlerchr commented 8 months ago

Mabye spotless ? https://github.com/diffplug/spotless

koppor commented 8 months ago

Wait for another PR - I have success with palantir-java-format.

That is a) more maintained and b) seems to work well and c) has better formatting than GJF:

(1) google-java-format output:

private static void configureResolvedVersionsWithVersionMapping(Project project) {
    project.getPluginManager()
            .withPlugin(
                    "maven-publish",
                    plugin -> {
                        project.getExtensions()
                                .getByType(PublishingExtension.class)
                                .getPublications()
                                .withType(MavenPublication.class)
                                .configureEach(
                                        publication ->
                                                publication.versionMapping(
                                                        mapping -> {
                                                            mapping.allVariants(
                                                                    VariantVersionMappingStrategy
                                                                            ::fromResolutionResult);
                                                        }));
                    });
}

(1) palantir-java-format output:

private static void configureResolvedVersionsWithVersionMapping(Project project) {
    project.getPluginManager().withPlugin("maven-publish", plugin -> {
        project.getExtensions()
                .getByType(PublishingExtension.class)
                .getPublications()
                .withType(MavenPublication.class)
                .configureEach(publication -> publication.versionMapping(mapping -> {
                    mapping.allVariants(VariantVersionMappingStrategy::fromResolutionResult);
                }));
    });
}
koppor commented 8 months ago

New try at https://github.com/koppor/jabref/pull/663