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

FR: Test rule for running google-java-format check #23

Open
davido opened this issue May 12, 2022 · 1 comment
Open

FR: Test rule for running google-java-format check #23

davido opened this issue May 12, 2022 · 1 comment

Comments

@davido
Copy link

davido commented May 12, 2022

Currently we are doing this outside of the build, e.g. with this alias:

  $ alias gjf
  alias gjf='git show --diff-filter=AMR --pretty="" --name-only HEAD | grep java$ | xargs -r /home/davido/projects/gerrit/tools/format/google-java-format-1.7 -i'

On Slack @shs96c commented how this test rule could be implemented:

We’ve not got a rule for that yet, but the process of writing one is simple enough:

o Create a java_google_format_test rule (it’s important that it’s a test rule!)

o Hook it into _create_lint_tests (the pattern should be obvious)

o Optionally create a rule that when run will actually do the reformatting

o Create either a config rule or just allow people to set True as the value for the workspace’s lint_setup

Once that’s done, anyone using the java_library, java_binary, java_test or java_export rules from contrib_rules_jvm can opt into the linting framework and have the google java formatter be part of their regular test suites.

Update

Linting can be disabled by adding a no-lint tag to any rule that needs it.
And for everything in a build file by using package_lint_config(linters = {}).

It was also pointed out, that there is another PR was uploaded upstream.

@davido davido changed the title FR: Test rule for running error prone lint checks FR: Test rule for running goole-java-format formatting checks Jun 29, 2022
@shs96c
Copy link
Collaborator

shs96c commented Jun 29, 2022

If we can expose the Google Format command as a *_test rule, then this will be easy to add.

@davido davido changed the title FR: Test rule for running goole-java-format formatting checks FR: Test rule for running google-java-format check Jun 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants