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

add Nonnull and Nullable annotations to ContextRun function #206

Closed
wants to merge 3 commits into from

Conversation

hiteshsharma
Copy link
Contributor

This change adds support for javax.annotation.Nonnull and javax.annotation.Nullable annotations for Parseq API.
This change is a follow up on discussion #205
This change only adds annotations for Task.contextRun method. Once this is accepted, I'll create more changes for adding annotations to other functions.
Annotations are decided based on current code usage.
@mchen07

…ons to other functions will be added in later changes
Copy link
Contributor

@mchen07 mchen07 left a comment

Choose a reason for hiding this comment

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

I have a little reservation that you picked this ContextRun function, as typical ParSeq users, these functions are too internal to them. I would encourage them to always try to use methods provided in Task class. So if we would like to add Nonnull or Nullable, I may prefer to start from there.

@hiteshsharma
Copy link
Contributor Author

@mchen07 agree. I just picked the first public function in Task.java to demonstrate the change. I plan to enable these for entire public API one function at a time. If you think beginning with some other function would be a good idea, I can send an update.

@mchen07
Copy link
Contributor

mchen07 commented Feb 12, 2019

I may prefer that we start with adding annotation to Task interface.

@hiteshsharma
Copy link
Contributor Author

@mchen07 reverted original commit and added @Nonnull annotations to map functions in Task interface. If this looks good, will do this for all default functions.
let me know what you think.

@@ -35,6 +35,7 @@ configurations {
}

dependencies {
compile group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.2'
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need to add this findbugs dependency? As we discussed earlier, I hope that this annotation should not depend on one particular static analysis tools.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

javax.annotation package is part of findbugs. This is just lib import, we don't need to run findbugs to use these annotations but if you're not willing to import lib as well then this change can't be made.
In my opinion importing this lib should not have any impact and it's a very standard practice.
let me know what you think.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mchen07 bump

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry for the delay. I am still struggling whether we should introduce such @nullable annotation where different IDE may have different support (for example, IntelliJ has its own @nullable support, which is different from javax.annotation, see https://www.jetbrains.com/help/idea/nullable-and-notnull-annotations.html), or instead we should use java Optional to indicate this, where we don't depend on the implementation of static code analysis tool.

Copy link
Contributor Author

@hiteshsharma hiteshsharma Feb 21, 2019

Choose a reason for hiding this comment

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

Hey @mchen07 documentation doesn't mentions it (probably old) but IntelliJ supports it. You can go to Intellij Preferences -> Editor -> Inspections -> Java -> Probable bugs -> @NotNull/@Nullable problems -> Configure annotations
There you can see javax.annotation.Nullable and Notnull too

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the tip @hiteshsharma. Have you seen this: spotbugs/spotbugs#180? Recently spotbugs is preferred over findBugs, will this have side effect on that trend?

@nickibi nickibi closed this Nov 3, 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