Skip to content

[java] NullAssignment false positive #629

@boris-petrov

Description

@boris-petrov

Rule: NullAssignment (java, errorprone)

Type type = condition ? something() : null;

This, according to NullAssignment's documentation, should not give the warning but it does.

PMD version 5.8.1.

P.S. Another false positive is:

String key;
if (a) {
	key = "a";
} else if (b) {
	key = "b";
} else {
	key = null;
}

This also should not give the warning.

P.S. Third example:

Type result = someHash.computeIfAbsent(a, _unused -> test ? truthy : null);

Metadata

Metadata

Assignees

Labels

a:false-positivePMD flags a piece of code that is not problematic

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions