Giter Site home page Giter Site logo

Comments (8)

bejibx avatar bejibx commented on May 17, 2024 1

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.

msridhar avatar msridhar commented on May 17, 2024

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.

bejibx avatar bejibx commented on May 17, 2024

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.

msridhar avatar msridhar commented on May 17, 2024

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.

msridhar avatar msridhar commented on May 17, 2024

@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.

msridhar avatar msridhar commented on May 17, 2024

btw for targeted suppressions, you can "downcast" any particular expression from @Nullable to @NonNull with a utility method; see here

from nullaway.

msridhar avatar msridhar commented on May 17, 2024

Gonna close this out as I think it's solved; @bejibx please let us know if you need further help

from nullaway.

bejibx avatar bejibx commented on May 17, 2024

Sorry for late response, yeah, I managed to fix those errors by implementing LibraryModels in separate module.

from nullaway.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.