Skip to content
This repository was archived by the owner on Dec 19, 2023. It is now read-only.

Verify google code format #599

Merged
merged 26 commits into from
May 3, 2021
Merged

Verify google code format #599

merged 26 commits into from
May 3, 2021

Conversation

oliemansm
Copy link
Member

Added plugin to verify google code format and updated the Contributions file explaining how to fix code formatting if the build fails because of the check.

It's as simple as running:

./gradlew googleJavaFormat

@setchy
Copy link
Member

setchy commented May 1, 2021

I'm struggling to remember the exact name of the tool, but I've seen other OSS repos where they commit their coding standards and IDE formatters to the root of their project. Could this be also useful in addition to the bot

@oliemansm
Copy link
Member Author

@setchy Looks like Spring Boot also has folders in the root for idea and eclipse with their code style settings: https://github.com/spring-projects/spring-boot. The contributions file doesn't really specify how to use those.

I've seen other projects where the default .idea folder with just the code style settings is part of the repo and all other files are ignored. That should automatically apply those code style settings to your project without needing to specifically import them. I could give something like that a try?

@oliemansm
Copy link
Member Author

The github action nicely fails showing clearly what's wrong, so I'll go ahead and fix the formatting in this one now:

image

@oliemansm
Copy link
Member Author

@setchy I've included the .idea/codeStyles folder now which contains the project code style settings in line with the bot. This should result in people using IntelliJ to automatically have the correct code style settings.

A lot of changed files now because of simple formatting changes.

/**
* @author <a href="mailto:[email protected]">oEmbedler Inc.</a>
*/
/** @author <a href="mailto:[email protected]">oEmbedler Inc.</a> */

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice email address :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤣

@@ -179,30 +195,32 @@ private void setQueryResolverClass(
* This is required, because normally implementations of interfaces are not explicitly returned by
* any resolver method, and therefor not added to the schema automatically.
*
* All interfaces are considered GraphQL interfaces if they are declared in the configured package
* and have at least one {@link GraphQLField}-annotated methods.
* <p>All interfaces are considered GraphQL interfaces if they are declared in the configured

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the closing tag missing intentionally?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The google-java-format plugin made this change automatically actually when I ran ./gradlew googleJavaFormat. So it seems to have been coded this way intentionally by Google.

@oliemansm
Copy link
Member Author

Looks like I'm not able to get IntelliJ to play completely nice with that gradle plug-in. Which is very annoying, because now I have to run that gradle task every time to correct it instead of being able to rely on IntelliJ reformatting it the same way. Not sure if this is really the way to go then... 🤔

@setchy
Copy link
Member

setchy commented May 2, 2021

Damn!

I haven't used this myself, but found it yesterday - https://github.com/jhipster/prettier-java - might be worth a look (no gradle plugin by the look though)

I'll do some further research to see if I can remember the library I forgot :p

@oliemansm
Copy link
Member Author

Thanks, I'll check it out. I'll also try to see if there's one common configuration to achieve using checkstyle.

@setchy
Copy link
Member

setchy commented May 2, 2021

What about a combination of https://github.com/google/google-java-format (IntelliJ or Eclipse plugin) with https://github.com/diffplug/spotless/tree/main/plugin-gradle#google-java-format for maven / gradle plugins

@oliemansm
Copy link
Member Author

Yeah that could work! The gradle plugin is already what this PR is using now. So that would mean that we'd have to add a section in the contributions doc explaining to install that plugin for your IDE too to make it all work. Haven't checked it out how that plugin works in the IDE.

@setchy
Copy link
Member

setchy commented May 2, 2021

I just tested it in IntelliJ.

Installed plugin, restart IDE, enable it per project (very nice) then Command+Option+L to reformat. It mentions the plugin doesn't handle organizing imports. To do that you need to set the File->Settings->Editor->Code Style. This might be where we use a Project specific file standard that we commit to git

@setchy
Copy link
Member

setchy commented May 2, 2021

I noticed the contributing.md mentions spectrum. I can update the wording tomorrow if no one beats me to it

UPDATE: reference removed

@sonarqubecloud
Copy link

sonarqubecloud bot commented May 3, 2021

@oliemansm oliemansm merged commit 3385712 into master May 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants