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

Remove nullable annotation configuration in fix serialization. #621

Merged
merged 4 commits into from
Jul 14, 2022

Conversation

nimakarimipour
Copy link
Contributor

@nimakarimipour nimakarimipour commented Jul 10, 2022

Following GH-517 If serializeFixMetadata is active, NullAway will serialize suggested type changes (currently just adding @Nullable). In the FixSerializationConfig file we can set a custom annotation that NullAway will use in the output serializations.

However, this process can be simplified by just asking NullAway to serialize type change locations with a default annotation name, any tool processing this output can use their own preferred annotation.

After this PR the following entity will be removed from the config .xml file:

<annotation>
       <nonnull> ... </nonnull>
       <nullable> ... </nullable>
</annotation

And a sample out below:

Field bar of Foo, ASSIGN_FIELD_NULLABLE, @Nullable

Will be changed to simply:

Field bar of Foo, ASSIGN_FIELD_NULLABLE, nullable

@nimakarimipour nimakarimipour requested review from msridhar and lazaroclapp and removed request for msridhar July 10, 2022 01:24
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.

Looks good to me and good refactoring/simplification. There is a missing comment to be deleted and a minor question, but otherwise looks good to me. Maybe worth testing this internally with a compatible version of the auto-annotator? Both to make sure all runs and to familiarize yourself with the process, @nimakarimipour .

/** Stores information suggesting a type change of an element in source code. */
public class SuggestedFixInfo {
/** Stores information suggesting adding @Nullable on an element in source code. */
public class SuggestedNullableFixInfo {

/** FixLocation of the target element in source code. */
private final FixLocation fixLocation;
/** Error which will be resolved by this type change. */
private final ErrorMessage errorMessage;
/** Suggested annotation. */
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove this comment as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

/** Stores information suggesting a type change of an element in source code. */
public class SuggestedFixInfo {
/** Stores information suggesting adding @Nullable on an element in source code. */
public class SuggestedNullableFixInfo {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why the rename here? It makes sense for now, but I wonder if we will have to flip it right back once we start adding other types of fixes? Or maybe the idea will be to add a common supertype for fixes and retain this one as a subclass?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did the renaming since instantiating this class only means we are suggesting Nullable and the value Nullable is hardcoded in this class. I though for better understanding the class purpose, I should refine the name.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sounds good for now. We might revisit this if we are adding other kinds of fixes, but right not it isn't clear if that will happen within NullAway or within the annotator or where, so this makes sense to me.

@nimakarimipour
Copy link
Contributor Author

Looks good to me and good refactoring/simplification. There is a missing comment to be deleted and a minor question, but otherwise looks good to me. Maybe worth testing this internally with a compatible version of the auto-annotator? Both to make sure all runs and to familiarize yourself with the process, @nimakarimipour .

Thank you for your comment. Sure, will do that @lazaroclapp

@nimakarimipour
Copy link
Contributor Author

Hi @lazaroclapp, I checked this internally with a compatible version of Annotator. Everything is working correctly, this is ready for review / merge.

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.

LGTM.

Feel free to merge when/if test pass. But please make the commit title "Remove nullable annotation configuration in fix serialization" (rather than "Removes") and make sure the squashed commit description is the PR's description, not the list of individual commit messages, please :)

@nimakarimipour nimakarimipour changed the title Removes nullable annotation configuration in fix serialization. Remove nullable annotation configuration in fix serialization. Jul 14, 2022
@lazaroclapp lazaroclapp removed the request for review from msridhar July 14, 2022 19:55
@lazaroclapp lazaroclapp merged commit 2198833 into uber:master Jul 14, 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

Successfully merging this pull request may close these issues.

2 participants