Skip to content

Update docs for CheckReturnValue #5419

@izeye

Description

@izeye

The "How to tell Error Prone which methods to check" section doesn't seem to reflect the changes made in #435.

It also would be better to expand the "Ignored contexts" section to fully reflect the following:

/**
* {@link FunctionalInterface}s that are generally used as a lambda expression for 'a block of
* code that's going to fail', e.g.:
*
* <p>{@code assertThrows(FooException.class, () -> myCodeThatThrowsAnException());
* errorCollector.checkThrows(FooException.class, () -> myCodeThatThrowsAnException()); }
*/
// TODO(glorioso): Consider a meta-annotation like @LikelyToThrow instead/in addition?
private static final Supplier<ImmutableSet<Type>> CLASSES_CONSIDERED_THROWING =
VisitorState.memoize(
state ->
Stream.of(
"org.junit.function.ThrowingRunnable",
"org.junit.jupiter.api.function.Executable",
"org.assertj.core.api.ThrowableAssert$ThrowingCallable",
"com.google.common.truth.ExpectFailure.AssertionCallback",
"com.google.common.truth.ExpectFailure.DelegatedAssertionCallback",
"com.google.common.truth.ExpectFailure.StandardSubjectBuilderCallback",
"com.google.common.truth.ExpectFailure.SimpleSubjectBuilderCallback",
"com.google.devtools.build.lib.testutil.MoreAsserts$ThrowingRunnable",
"com.google.gerrit.testing.GerritJUnit$ThrowingRunnable")
.map(state::getTypeFromString)
.filter(Objects::nonNull)
.collect(toImmutableSet()));

See https://errorprone.info/bugpattern/CheckReturnValue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions