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

Adding support for JSR-305 annotations #645

Merged
merged 3 commits into from
Dec 4, 2016

Conversation

shrey-garg
Copy link
Contributor

Adding support for JSR-305 compatible annotations, for defect detection using libraries like google's find bugs or while using Intellij Idea IDE etc.

It adds @nonnull annotations for all fields that are marked required and @nullable on all fields that are not.

@shrey-garg shrey-garg changed the title Adding supprot for adding JSR-305 annotations Adding support for JSR-305 annotations Nov 12, 2016
@joelittlejohn
Copy link
Owner

Thanks @shrey-garg. I note that JSR-305 is dormant, which I guess means it is not going anywhere and is unlikely to ever be added to Java.

Thanks for putting this behind a configuration option. I've never come across this JSR before but I don't have any objections to adding this. I'll take a detailed look through the code and comment on anything that needs to change.

@shrey-garg
Copy link
Contributor Author

Thank you.

Will incorporate any suggestions that you might have.

Copy link
Owner

@joelittlejohn joelittlejohn left a comment

Choose a reason for hiding this comment

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

I think you also need to look at RequiredArrayRule.java ("required": true|false can appear on a property in draft03 style and draft04+ style has "required" as an array of property names on an object).

Also, this needs some integration tests. Check out IncludeJsr303AnnotationsIT.java.

@@ -458,6 +460,19 @@ public void setIncludeJsr303Annotations(boolean includeJsr303Annotations) {
}

/**
* Sets the 'includeJsr303Annotations' property of this class
Copy link
Owner

Choose a reason for hiding this comment

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

Typo here, this should be 305

Copy link
Contributor Author

Choose a reason for hiding this comment

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

corrected

@shrey-garg
Copy link
Contributor Author

I have made changes to take RequiredArrayRule into consideration and have also added integration tests which validate if the proper annotations have been added or not.

@joelittlejohn
Copy link
Owner

@shrey-garg This looks good. The only thing I'm going to do here is remove NotRequiredRule.java, because I don't think that it's right to add these comments to all existing code. It's a lot of noise for all projects.

@shrey-garg
Copy link
Contributor Author

shrey-garg commented Dec 4, 2016

@joelittlejohn The NotRequired comment should only be added if the JSR-305 flag is on, it won't be added in any other scenario.

@joelittlejohn
Copy link
Owner

Ah, so it is. I misread this. Thanks!

@joelittlejohn joelittlejohn merged commit 9ce569a into joelittlejohn:master Dec 4, 2016
@joelittlejohn joelittlejohn added this to the 0.4.28 milestone Dec 5, 2016
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