Skip to content

[false-negative]ToStringReturnsNull can not detect the case return condition ? foo : null #1659

@wuchiuwong

Description

@wuchiuwong

Description of the problem / feature request:

ToStringReturnsNull can not detect the case return condition ? foo : null
This rule is implemented in error_prone_core-2.3.4-sources.jar!\com\google\errorprone\bugpatterns\ToStringReturnsNull.java,
and use node.getExpression().getKind() == NULL_LITERAL; to check whether null is returned,
Therefore, it will not detect those return null statements that make logical judgments when returning.

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

@Override
public String toString() {
	return this.mode == 'd' ? this.writer.toString() : null;
}

What version of Error Prone are you using?

2.3.4

Have you found anything relevant by searching the web?

no

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