Skip to content

Enable lint and errorprone checks in Jdk11 #289

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

Merged
merged 2 commits into from
Apr 20, 2021

Conversation

karllessard
Copy link
Collaborator

This PR enables lint checks from javac and Google's errorprone plugin. It's enabled only in JDK11 mode for now, since errorprone won't work with standard javac compiler of JDK8.

Right now I've enabled only default error and warning checks in errorprone since adding them all increase drastically the compilation time (see the list of all checks available here).

We'll readjust and add more checks if needed, plus clear all warnings that we already have in a separate PR.

@karllessard
Copy link
Collaborator Author

Ok closing this, I thought that forcing JDK11 in the quick-build but using the GitHub setup-java action could have helped somehow with the framework's javadoc issue but looks like not. I'll reopen it later if I find another way to prevent that annoying issue with GitHub Actions.

@Craigacp
Copy link
Collaborator

We might need to use setup-java v2 to pick the distribution. We can select Zulu, which is what was used up until a few months ago, maybe that will work?

@Craigacp
Copy link
Collaborator

Also maybe we could have the lint checks be a separate action? That way it doesn't matter as much what jdk they are run under.

@rnett
Copy link
Contributor

rnett commented Apr 16, 2021

Also maybe we could have the lint checks be a separate action? That way it doesn't matter as much what jdk they are run under.

I'll second this, it's nice to know if your build is failing b/c lint or test failures.

Also, would it be possible to have a maven goal to auto-format (i.e. fix issues)?

@karllessard
Copy link
Collaborator Author

I’m not sure how that would work in a separate action. Lint checks need to be ran, afaik, at compile time. So we’ll need to compile it twice?

@Craigacp , I think by default the setup-java is taking Zulu for Java 11 and you need to specify adopt for using it, I’ve tried both but it failed. I’ll try later by setting explicitly zulu if that fixes it.

@rnett I’m not aware of any plugin auto-formatting the code but haven’t look for it neither. Might be interesting but at the same time, I’d prefer that the PR we merge are already formatted properly instead of relying “blindly” on a plugin. We coule add some sort of “checkstyle” step though to flag bad formatting, the lint checks I have added are mostly for detecting coding mistakes

@rnett
Copy link
Contributor

rnett commented Apr 17, 2021

I’m not sure how that would work in a separate action. Lint checks need to be ran, afaik, at compile time. So we’ll need to compile it twice?

I guess so, I don't think that would be a huge deal in dev mode? It's just nice when you can tell if your PR is failing b/c tests, or b/c lint errors by looking at the GitHub actions, rather than having to dig through the log. I don't think you could compile and lint in one action and then have the test action depend on it, but that would be ideal.

I’m not aware of any plugin auto-formatting the code but haven’t look for it neither. Might be interesting but at the same time, I’d prefer that the PR we merge are already formatted properly instead of relying “blindly” on a plugin. We could add some sort of “checkstyle” step though to flag bad formatting, the lint checks I have added are mostly for detecting coding mistakes

Ah, yeah, I'm thinking of enforcing google-java-format, not error detection. Were you planning on doing that here or would it be a separate PR? Either way, I'm not proposing we do the auto-format as part of the CI, but a way to correctly format a file other than doing it manually would be nice, for people who don't have google-java-format in their IDE.

@karllessard
Copy link
Collaborator Author

Testing by setting explicitly zulu JDK11 distribution

@karllessard karllessard reopened this Apr 20, 2021
@karllessard
Copy link
Collaborator Author

Ok so I finally got the build on JDK11 working again, by installing openjdk on centos manually. So it looks like @Craigacp and @rnett are agreeing on running the lints in a separate action, I'll do it. Also @Craigacp ask me to enable support for JDK16 according to these instructions, which I'll do as well.

@karllessard
Copy link
Collaborator Author

Also, would it be possible to have a maven goal to auto-format (i.e. fix issues)?

On this @rnett , I've just found a few interesting links related to auto-formatting on build (or even on Git push): https://github.com/google/google-java-format#third-party-integrations

@karllessard
Copy link
Collaborator Author

Ok so I've updated the PR, now lint checks are automatically enabled as soon as you run on JDK9+ (no matter if jdk11 profile is enabled).

They can be disabled explicitly by passing -Dlint.skip=true to the command line, which I do in the first step of the CI quick build before re-compiling without it. So lint errors will be raised distinctively.

Copy link
Collaborator

@Craigacp Craigacp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Craigacp Craigacp merged commit 2eca4f0 into tensorflow:master Apr 20, 2021
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

Successfully merging this pull request may close these issues.

3 participants