Comments (8)
In addition to these options, NullAway will look for any classes implementing the com.uber.nullaway.LibraryModels interface...
It seems I have to use compile
dependency instead of annotationProcessor
to do so, which will add a lot of uneccessary dependencies (including huge Guava library) to my project, which I want to avoid.
from nullaway.
NullAway is not able to reason across procedure calls to prove the original example safe. Doing so could slow the tool down considerably. That said, is this a well-known StringUtils
class from a standard library? If so we could maybe add a library model to catch this case.
from nullaway.
No, this is my own utility class. Actually, I used TextUtils#isEmpty(CharSequence) initially, but migrate to my own method because IntelliJ IDEA code inspections running on CI server were not able to analyze these situations properly. If NullAway is ok with android method I can potentially migrate back (which I don't want to do, because it is a LOT of code), but there are many other places in app, where similar null-checking logic involved. I also don't like to supress those warnings because I have to supress whole method, which is ok for above example, but may be unacceptable for larger methods. Maybe add an option to supress warning using comments similar to how Lint inspections being supressed?
//noinspection NullAway
return StringUtils.isEmptyOrNull(text) ? "Hello World!" : text;
from nullaway.
I think a good option here would be for you to add your own library model actually. The process is documented here, but the docs are a bit sparse. We should add a sample library model to show how it's done. We'll work on that, but if you figure it out in the meantime let us know.
from nullaway.
@bejibx I just added a sample library model on master; see #53. It's used by the sample app just by adding an annotation processor dependency; no need to pollute your app's classpath. Does this look like a reasonable solution?
from nullaway.
btw for targeted suppressions, you can "downcast" any particular expression from @Nullable
to @NonNull
with a utility method; see here
from nullaway.
Gonna close this out as I think it's solved; @bejibx please let us know if you need further help
from nullaway.
Sorry for late response, yeah, I managed to fix those errors by implementing LibraryModels
in separate module.
from nullaway.
Related Issues (20)
- Wiki Jakarta Annotations API HOT 2
- Missing check for library models for lambdas with an expression body
- jdk Files false positive/wrong line HOT 3
- Update JSpecify package in docs HOT 1
- The combination of JSpecify + Lombok does not seem to work well HOT 6
- Method references of nullable instances are not detected HOT 1
- Detected NPE causes EP's Var rule to go nuts. HOT 5
- Validation of null in a switch-case with pattern matching does not work as expected. HOT 1
- False positive warning on switch statements with case null
- Build failure : 'options.compilerArgumentProviders.errorprone$0.name' is missing an input or output annotation. HOT 1
- Support org.apache.commons.lang3.StringUtils.isNotEmpty HOT 3
- Support for `collect()` in Streams API HOT 4
- Control flow analysis fails within a stream collector HOT 5
- Validation of null in a method used in a boolean expression does not work as expected. HOT 1
- `if (Foo.this.bar != null)` in nested class not properly analyzed HOT 1
- Rename the Jar Infer Flags `JarInferEnabled`,`JarInferUseReturnAnnotations`
- Variable checked non-null outside a `forEach` or `Stream` lambda triggers an error HOT 13
- `if` statement on a boolean does not prevent a dereferenced nullable error HOT 1
- Null `if` check and failing function to taken in account HOT 2
- Extract methods in StreamNullabilityPropagator
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nullaway.