Add eclipse formatter in maven spotless plugin#6807
Add eclipse formatter in maven spotless plugin#6807mqliang wants to merge 3 commits intoapache:masterfrom mqliang:fmt-enforce
Conversation
Jackie-Jiang
left a comment
There was a problem hiding this comment.
A lot of changes are not in sync with the intellij format. I think most of the developpers are using intellij to format the code. Let's try to make the plug-in the same behavior as auto-formatting with intellij
Codecov Report
@@ Coverage Diff @@
## master #6807 +/- ##
============================================
- Coverage 74.00% 66.08% -7.93%
Complexity 12 12
============================================
Files 1414 1414
Lines 68886 68639 -247
Branches 9942 9935 -7
============================================
- Hits 50979 45360 -5619
- Misses 14569 20048 +5479
+ Partials 3338 3231 -107
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
The level of difficulty is extremely high:
So, what we can do is either:
Or
Option 2 can force the whole codebase formatted in a consistent way, but not match the intellij auto-formatting behavior. |
|
@mqliang
|
For "new line for exception", in Intellj, it's corresponding option is called "always wrap throws keyword": Unfortunately, Eclipse formatter does not has such a option, here is a complete list of Eclipse formatter options: https://github.com/eclipse/eclipse.jdt.core/blob/7e35bbd8b9cc36a449e562c61841f9968ec4bec3/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java#L122-L524 For So, it's almost impossible to make the maven plugin be consistent with IntellJ behavior if we use eclipse formatter given that IntellJ/Eclipse provide different options. If we wanner keep consistency across IntellJ IDE, Eclipse IDE and maven plugin, the only choice is the google formatter, which has plugin for both IntellJ/Eclipse/Maven. The drawback is:
|
Jackie-Jiang
left a comment
There was a problem hiding this comment.
Seems the most changes are caused by putting throws on the same line. I'm okay with it if there is no workaround.
In general, we want to keep minimal changes to the current code and migrate to the eclipse formatter.
Please announce this change in the pinot-dev channel and schedule a time to merge this change. The changes in this PR could cause several conflicts, and contributors should be notified so that they can rebase the changes accordingly.
| _brokerConf.addProperty(Broker.CONFIG_OF_BROKER_ID, _brokerId); | ||
| } | ||
|
|
||
| public static HelixBrokerStarter getDefault() throws Exception { |
There was a problem hiding this comment.
Can we change the formatter to not force the order of the methods?

Description
Add eclipse formatter in maven spotless plugin. "org.eclipse.jdt.core.compiler.source" should be set as 1.8 otherwise spotless plugin will panic.
cc @Jackie-Jiang @fx19880617
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-notesand complete the section on Release Notes)Release Notes
Documentation