Skip to content
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

Automate code formatting using Maven (2019 rules) #2495

Closed

Conversation

walles
Copy link
Contributor

@walles walles commented Apr 2, 2021

Same as #2494 but with HBase rules from 2019 (the other PR uses the existing 2014 ruleset).

Before this change

CONTRIBUTING.md encouraged reformatting sources using make format.

make format would reformat lots of files, not just the ones you changed.

With this change in place

Any mvn operation will implicitly format sources.

CI will validate code formatting.

This implicitly means that people have to at least mvn compile their sources locally before making PRs to make sure they don't get refused by CI.

This enforces good practice, regardless of the actual formatting.

Notes

Files to be reviewed (the rest have been auto formatted):

  • pom.xml
  • Makefile
  • .github/CONTRIBUTING.md

Also, checking the commits list might be easier than looking at files changed, all reformatting is confined to the last change.

The code formatting Maven plugin being used didn't have any validate goal so I replaced with another one.

Still running the Eclipse formatter though, so hbase-formatter.xml still works.

hbase-formatter.xml has been updated to a newer one from 2019.

@walles walles closed this Apr 2, 2021
@walles walles reopened this Apr 2, 2021
@walles walles force-pushed the walles/format-on-mvn-validate-in-ci-2019 branch from f06c914 to dfda2f1 Compare April 2, 2021 13:13
@walles walles force-pushed the walles/format-on-mvn-validate-in-ci-2019 branch from dfda2f1 to 0f869c2 Compare April 2, 2021 14:57
@walles
Copy link
Contributor Author

walles commented Apr 2, 2021

The formatter considered by hash that my files were already formatted since #2494 and ignored them after I upgraded the formatting rules, had to make some attempts to get around that.

Should be good now.

@walles
Copy link
Contributor Author

walles commented Apr 2, 2021

Formatter caching problem reported here: revelc/formatter-maven-plugin#453

@walles
Copy link
Contributor Author

walles commented Oct 17, 2021

Closing.

If somebody wants to revive this, any Java conflicts could probably be fixed by:

  1. Dropping the last commit (Run "mvn compile" to get sources formatted)
  2. Rebase on latest master
  3. mvn compile to reformat the code
  4. Commit and push reformatting changes as a new Run "mvn compile" to get sources formatted change
  5. Force push since you just replaced a commit

@walles
Copy link
Contributor Author

walles commented May 5, 2022

@sazzad16, just out of curiosity, what kind of discussion do you think would be needed?

Are the instructions in CONTRIBUTING.md still valid?

@sazzad16
Copy link
Contributor

sazzad16 commented May 5, 2022

@walles

what kind of discussion do you think would be needed?

It's mostly "when" would we want to merge the change as it's likely to invalidate all the existing PRs.

Are the instructions in CONTRIBUTING.md still valid?

Yes. (We should improve it. But current one doesn't seem wrong.)

@walles
Copy link
Contributor Author

walles commented May 12, 2022

Are the instructions in CONTRIBUTING.md still valid?

Yes. (We should improve it. But current one doesn't seem wrong.)

The instructions say:

  • You can run make format anytime to reformat without IDEs

Which will change tons of code, invalidating all other PRs.

So CONTRIBUTING.md actually does contain instructions that don't work.

@sazzad16
Copy link
Contributor

  • You can run make format anytime to reformat without IDEs

@walles Thanks. Striking it for the time being.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants