Open codylerum opened 2 years ago
Hey Cody,
Thanks for filing this. Good news --- it's something we're actively working on!
We're in the process of trying to "flip the default" for the language (at least, internally at Google), which means we'll have to allow "side-caring" of both @CheckReturnValue
and @CanIgnoreReturnValue
to unannotatable APIs (e.g., third party APIs or JDK APIs).
@kluever Perfect, I guess that means no PR for me to write. I'll keep an eye out for it to arrive.
I'm interested in this as well. Is this still being worked on?
/cc @cgdecker
We're making progress towards flipping the default inside of Google.
Right now, the checker uses a centralized exclusion list of APIs where the return value doesn't need to be checked (this is important for 3p APIs and JDK APIs which cannot be directly annotated).
We're still doing some refactoring of all of this, but we expect to be able to open source that in the coming months.
Thanks.
I'm not sure if this exists or is something that would need to be added, but I ran though the documentation and source and I didn't see anything.
What I would like to be able to do is via a command line flag like
<arg>-XepOpt:ReturnValueIgnored:TypeToCheck=javax.persistence.criteria.Predicate</arg>
And have the checker throw a warning if an a type of javax.persistence.criteria.Predicate for example is returned (like already exists for
java.math.BigDecimal
) and not used. This is for a library where I cannot annotate the relevant methods.Existing types: https://github.com/google/error-prone/blob/master/core/src/main/java/com/google/errorprone/bugpatterns/ReturnValueIgnored.java#L65
Example method: https://javaee.github.io/javaee-spec/javadocs/javax/persistence/criteria/CriteriaBuilder.html#equal-javax.persistence.criteria.Expression-javax.persistence.criteria.Expression-