-
Notifications
You must be signed in to change notification settings - Fork 285
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
Augment error serializarion info #643
Augment error serializarion info #643
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally looks good to me, though I think the testing infra has a couple bugs (see comments below).
One other thing I wonder is about the headers of the TSV. "class" and "method" are very generic, and they aren't the class or method where the error is happening, but the class and method referenced at the point the error is happening... maybe "target_class", "target_method", etc? Not sure if there is a better name than that, since it's sometimes the method being called and sometimes the method being overridden, etc. (cc: @msridhar )
@@ -50,16 +77,19 @@ public boolean equals(Object o) { | |||
} | |||
ErrorDisplay that = (ErrorDisplay) o; | |||
return type.equals(that.type) | |||
// To increase readability, a shorter version of the actual message might be present in the | |||
// expected output of tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we removing this comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the notice, added it back
e9182db
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(type, message, method, clazz); | ||
return Objects.hash(type, message, encMethod, encClass); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that this has a lot more fields, shouldn't those be part of its hashCode()? This was all fields before, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was all fields before, but according to the usage of these classes which are mostly used in test cases and are compared to at most 3/4
other instances, I did not see it necessary to include all fields. But you are right, it is better to be more precise about the hash.
"test(java.lang.Object)", | ||
"METHOD", | ||
"com.uber.Super", | ||
"test(java.lang.Object", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't there a missing ')'
here? And shouldn't the test fail because of it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes it should fail, updated the test.
&& encMethod.equals(that.encMethod) | ||
&& encClass.equals(that.encClass) | ||
&& kind.equals(that.kind) | ||
&& clazz.equals(that.clazz) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is missing comparing this.method
, which I believe is why that test case with the missing parenthesis succeeds...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much for noticing this, I just used the intellij generated code. updated it: 258a341
@@ -25,23 +25,23 @@ | |||
import com.google.errorprone.util.ASTHelpers; | |||
import com.sun.source.util.TreePath; | |||
import com.uber.nullaway.ErrorMessage; | |||
import com.uber.nullaway.fixserialization.location.FixLocation; | |||
import com.uber.nullaway.fixserialization.location.SymbolLocation; | |||
import java.util.Objects; | |||
|
|||
/** Stores information suggesting adding @Nullable on an element in source code. */ | |||
public class SuggestedNullableFixInfo { | |||
|
|||
/** FixLocation of the target element in source code. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is outdated given the renaming.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also ran git grep FixLocation
, there is no usage of FixLocation
anymore.
+ '\t' | ||
+ "index" | ||
+ '\t' | ||
return "kind" + '\t' + "class" + '\t' + "method" + '\t' + "param" + '\t' + "index" + '\t' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this auto-formatted? I think it looks better in the previous/existing code (unless GJF recommends this style)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since Java 1.8 there's String#join(CharSequence delimiter, CharSequence... elements)
, so another option would be:
String.join("\t", "kind", "class", "method", "param", "index", "uri")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. @nimakarimipour, probably a good idea to do this in all the places we are performing these tab-separated string concatenations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Stephan202 thank you for the suggestion :)
@lazaroclapp replaced all multiple calls with single join
call.
@lazaroclapp Resolved all comments and changed headers to use ( Regarding changing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀 !
#### ~~This PR is Built upon GH-51~~ GH-51 is landed. ----- This PR resolves #47 by updating `Error` instance creation according to the latest changes. In the new release of NullAway (Specifically [PR643](uber/NullAway#643)), information of the non-null target (the element involved in the pseudo-assignment of a @nullable expression into a @nonnull and causing the error) is serialized along the reporting errors in the `errors.tsv`. Header of `errors.tsv` files is changed from below: ``` MESSAGE_TYPE MESSAGE CLASS METHOD ``` to: ``` message_type message enc_class enc_method target_kind target_class target_method param index uri ``` This requires updates on how `Error` instances are created due to change in `errors.tsv` files contents. ----- ~~Note: tests for `core` module are temporarily excluded in this PR for CI as they are only compatible with NullAway verion `0.9.10`.~~ _All_ tests are included since `NullAway 0.9.10` is released.
This PR augments error information serialized by NullAway. At current state, if
SerializeFixMetada
is active, all reporting errors will be serialized toerrors.tsv
output file where each row has the format below:The above information does not contain any information regarding the
element
which involved in a pseudo-assignment of a@Nullable
expression into a@NonNull
. This information is crucial to detect origins of the error and other computable features.With this PR, the format of the
errors.tsv
is changed to below to serialize all the required information to denote the involved element in the error:This PR involves other small refactoring (mostly renaming) as it was necessary to reuse the existing methods to produce the desired outputs.