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

Upgrade to Error Prone 2.3.3 #295

Merged
merged 2 commits into from Apr 8, 2019
Merged

Upgrade to Error Prone 2.3.3 #295

merged 2 commits into from Apr 8, 2019

Conversation

ZacSweers
Copy link
Contributor

Most of the noise in this diff falls under a few categories:

  • UnusedVariable check
  • Strong enforcement of immutables (no mixing, using them in autovalue)
  • Use Types.isSameType() for type comparisons (instead of .equals())
  • Use state.getSourceForNode() for representing trees rather than Tree#toString()
  • Use fluent APIs for assertions in tests

Resolves #286

Most of the noise in this diff falls under a few categories:
- UnusedVariable check
- Strong enforcement of immutables (no mixing, using them in autovalue)
- Use Types.isSameType() for type comparisons (instead of .equals())
- Use state.getSourceForNode() for representing trees rather than Tree#toString()
- Use fluent APIs for assertions in tests

Resolves uber#286
Copy link
Collaborator

@lazaroclapp lazaroclapp left a comment

Choose a reason for hiding this comment

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

Isn't this still blocked on faster buck support for XPlugin? We don't want to make upstream NullAway incompatible with our internal infra.

@ZacSweers
Copy link
Contributor Author

Isn't this still blocked on faster buck support for XPlugin? We don't want to make upstream NullAway incompatible with our internal infra.

That issue started with 2.3.2 though, which NullAway is already on. That's why I thought this was fair game :). We can also roll it back to 2.3.2 and keep most of the fixes for things it raised for now as a preparation step.

@msridhar
Copy link
Collaborator

msridhar commented Apr 1, 2019

I think it’s fine to update to EP 2.3.3 for building NullAway. But NullAway probably shouldn’t have a dependency on EP >= 2.3.2. Can we tease these apart?

@ZacSweers
Copy link
Contributor Author

Let me take a look at separating them. Want to reiterate though that we're already on 2.3.2, which has the plugin change. 2.3.3 wouldn't be a new change in that regard

@msridhar
Copy link
Collaborator

msridhar commented Apr 2, 2019

Yeah we’ve been sloppy. The important thing is to not use any APIs introduced in 2.3.2 or later, for now.

@ZacSweers
Copy link
Contributor Author

Alright I've separated the error prone API version from the one used to build against, and lowered the API version to 2.3.1 in d01f759

Let me know what you want to do about the other comments!

Copy link
Collaborator

@lazaroclapp lazaroclapp left a comment

Choose a reason for hiding this comment

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

Some nits/questions/musings, but, overall, happy to merge this! Thanks, Zac! @msridhar ?

@@ -16,7 +16,8 @@

def versions = [
checkerFramework : "2.5.5",
errorProne : "2.3.2",
errorProne : "2.3.3", // The version of error prone running on this project
errorProneApi : "2.3.1", // The version of error prone built against and shipped
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍 I dream of a day they once again are both one and the same, but, for now, thanks for this :)

@@ -919,7 +917,7 @@ private boolean fieldAlwaysInitializedBeforeRead(
if (classTreePath == null) {
throw new IllegalStateException(
"could not find enclosing class / enum / interface for "
+ enclosingBlockPath.getLeaf());
+ state.getSourceForNode(enclosingBlockPath.getLeaf()));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Minor concern here: state. getSourceForNode performs file IO to retrieve the code, where JTree.toString() uses a visitor to reconstruct the string representation from the in-memory AST. This means toString() is faster. As long as we are only calling getSourceForNode for reporting actual errors (with imply IO anyways), it's probably fine to call this API, but we don't want to use it anywhere else, as it might cause a performance regression.

Related: getSourceForNode uses CompilationUnitTree.getSourceFile, which just reads JCCompilationUnit.sourcefile in JavaC. Do we know if that field is always set? Can javac operate on streams of java sources that are not files? (The JVM certainly can when loading bytecode, so... )

Either way, I think this is all fine for our use cases until we see an issue from this (either performance related or with getting the file) but well... any thoughts, @msridhar ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is fine I think. We should not be turning ASTs into Strings in any perf-critical computation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep agreed. Double checked and this is only used in exception messaging

}
ImmutableSet.Builder<Element> resultBuilder = ImmutableSet.builder();
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

@@ -17,6 +17,7 @@

private CompilationTestHelper compilationHelper;

@SuppressWarnings("CheckReturnValue")
Copy link
Collaborator

Choose a reason for hiding this comment

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

The documentation for "CheckReturnValue" is unusually unhelpful. But from what I understand, this is complaining that we are not "using" the result from .newInstance(...), even though we are assigning it to a field, correct?

The weird thing is, this seems like perfectly idiomatic Error Prone test code, e.g.: https://github.com/google/error-prone/blob/master/test_helpers/src/test/java/com/google/errorprone/CompilationTestHelperTest.java#L45

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah I don't fully understand why we need to suppress here either

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's because setArgs is annoyingly marked as @CheckReturnValue, as they marked the entire package with that annotation

Copy link
Collaborator

@msridhar msridhar left a comment

Choose a reason for hiding this comment

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

Thanks for the great cleanup!

@lazaroclapp lazaroclapp merged commit 26b3f55 into uber:master Apr 8, 2019
lazaroclapp added a commit that referenced this pull request Apr 8, 2019
PR #300 introduces a code pattern that is linted against after #295.
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.

None yet

3 participants