Java icon indicating copy to clipboard operation
Java copied to clipboard

[FEATURE REQUEST] Java Code Formatter

Open debasishbsws opened this issue 2 years ago • 3 comments

What would you like to Propose?

The current Clang format linter definitely does its job to identify linting errors in the code. But I think it will be better if we could have a formatter that we can integrate with CI jobs to auto-formate code if possible. Therefore, I am trying to propose a Java formatter.

Issue details

Currently, contributors have to format the code manually.

Additional Information

The fotmatter I am proposing is called Spotless.

The Pros for choosing Spotless:

  • Just run mvn spotless:apply does magic.
  • It is widely used, and actively maintained!
  • Can be integrated with CI.
  • It supports many different formatting policies (google java style, eclipse jdt...).
  • Support with IntelliJ IDEA and VSCode

debasishbsws avatar Jun 30 '23 18:06 debasishbsws

@siriak what is your thought on this?

debasishbsws avatar Jun 30 '23 18:06 debasishbsws

I think it's a great idea. Having a formatter is better than only having a check.

siriak avatar Jun 30 '23 19:06 siriak

Great idea. The clang-format-lint-action support format the code inplace

name: Run clang-format Linter

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - uses: DoozyX/[email protected]
      with:
        source: '.'
        exclude: './lib'
        extensions: 'h,cpp,c'
        clangFormatVersion: 16
        inplace: True
    - uses: EndBug/add-and-commit@v9
      with:
        author_name: Clang Robot
        author_email: [email protected]
        message: 'Committing clang-format changes'
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

acbin avatar Jul 01 '23 03:07 acbin

Hello, I would like to work on this, can it be assigned to me, please

abhisheksharma010 avatar Jul 10 '23 00:07 abhisheksharma010

@abhisheksharma886 go ahead

debasishbsws avatar Jul 10 '23 03:07 debasishbsws

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Sep 05 '23 00:09 github-actions[bot]

Please reopen this issue once you add more information and updates here. If this is not the case and you need some help, feel free to seek help from our Gitter or ping one of the reviewers. Thank you for your contributions!

github-actions[bot] avatar Sep 13 '23 00:09 github-actions[bot]