-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add spotless maven plugin to enforce java format. #6782
Conversation
@mcvsubbu @Jackie-Jiang @fx19880617 @siddharthteotia @mayankshriv Update: just found that the maven plugin support eclipse code formatter profile. Add the corresponding config and eclipse code style xml file in the 3rd commit. The xml file ( You may noticed that we already have a
I guess it's because the In conclusion, there are 3 options to apply more strict formatting:
I prefer the 3rd option and update the the current codestyle-eclipse.xml as new content. Any thoughts? |
Codecov Report
@@ Coverage Diff @@
## master #6782 +/- ##
=============================================
- Coverage 74.14% 43.55% -30.60%
+ Complexity 12 7 -5
=============================================
Files 1412 1412
Lines 68762 67930 -832
Branches 9934 9928 -6
=============================================
- Hits 50986 29584 -21402
- Misses 14461 35821 +21360
+ Partials 3315 2525 -790
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Nice work! We need to be very careful on the code style and keep it compatible with the current Pinot style. I believe the current eclipse style is compatible with the intellij style. We probably should update the existing eclipse style to the latest version. The end goal here should be giving the same result as the IDE auto-format. |
The codestyle-intellj.xml file can be deleted now. Intellj support import eclipse code formatter settings since 2014. I have tried |
@mqliang Yes I totally agree maintaining one file is easier and more desired. I'm not sure if eclipse style tracks all the available options in the intellij style. If not, let's try to keep the current style as much as possible because most of the files already follow the format. When enabling the plugin, only the files that do not follow the current style should be changed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we change the import rule to have static import after the regular import? We should keep the current order
Specified the import order as: java, javax, org, com, other unspecified, static import. |
I think we are following alphabetical order on regular import, followed by static import |
Done. Now all imports are split into two section: regular import in alphabetical order, static import |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! Well done!
Description
ref #6727
This change add a spotless maven plugin to enforce java format.
If java file is not formatted properly, all pipelines of
Pinot Tests / Pinot Quickstart on JDK XXX
will failed and hint developer to runmvn spotless:apply
to fix the violation.NOTE:
Currently, just add two basic rules:
It's possible to add some more strict rules (via the goolge-formatter or the prettier-formatter ). For example, if we add the prettier formatter as follows in the plugin configuration:
It will use 2 spaces as indention and format all function definition/calling code as using one line for each parameter, e.g.
the goolge-formatter can not be used in our case, since it will mess up license headers, see google/google-java-format#168
@mcvsubbu @Jackie-Jiang @fx19880617 @siddharthteotia @mayankshriv I think we may need to discuss whether to adopt the code style of "one line for each parameter in function definition/calling code". I will add the prettier formatter configuration if need be.
Upgrade Notes
Does this PR prevent a zero down-time upgrade? (Assume upgrade order: Controller, Broker, Server, Minion)
backward-incompat
, and complete the section below on Release Notes)Does this PR fix a zero-downtime upgrade introduced earlier?
backward-incompat
, and complete the section below on Release Notes)Does this PR otherwise need attention when creating release notes? Things to consider:
release-notes
and complete the section on Release Notes)Release Notes
Documentation