Skip to content

ParameterNotNullable should detect null checks in commons-lang StringUtils #1044

@zman0900

Description

@zman0900

What version of Error Prone are you using?

2.3.1

Does this issue reproduce with the latest release?

2.3.1 is latest

What did you do?

  • -Xep:ParameterNotNullable:WARN
import org.apache.commons.lang3.StringUtils;
import javax.annotation.Nullable;

public class MyClass {
    @Nullable
    public Character doTheThing(@Nullable final String str) {
        Character result = null;
        if (StringUtils.isNotEmpty(str)) {
            result = str.charAt(0);
        }
        return result;
    }
}

What did you expect to see?

No warning.

What did you see instead?

[ParameterNotNullable] Nullable parameter not checked for null.


It would be useful if ParameterNotNullable could detect the null checking that happens inside this call to StringUtils#isNotEmpty and other similar method inside commons-lang, or maybe even other libraries.

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