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
CanBeNonNullable false positive #5331
Comments
This is an expected behavior. The function does nothing when the value is null so it should not allow null values in the first place. If you really want to keep the function signature I think that a |
Thanks. If I make it non-null then I can remove the method, but then I need to put the null check outside of every usage.
|
(feel free to move this to a discussion) |
Yes, that's the idea, to move the check up instead of inside the function. Don't have functions that do "nothing". But as I said, if that have sense for your use case you can always |
@BraisGabin added your explanation to the rule: #5332 (We follow the same pattern at work, btw, ifs outside.) |
Steps to Reproduce
Expected Behavior
No flagging.
Observed Behavior
Context
The whole point of this method is to hide the nullability in a named nice fun. The method does the null check, so that it can be just called, and the lambda doesn't have to deal with a null-check. It allows this change:
which actually fixes
NestedScopeFunctions
.I'm not entirely sure this is a false positive, I could be mis-interpreting what
CanBeNonNullable
does.Your Environment
The text was updated successfully, but these errors were encountered: