Hi,
when declaring a function that has for example org.eclipse.draw2d.geometry.Vector
as return type and returns null
an issue is raised that an empty collection should be returned instead. This is impossible because this class is no java.util.Collection
.
public class EmptyCollection {
public Vector func(boolean selector) {
if (selector) {
return null;
// ^^^^
// Return an empty collection instead
} else {
return new Vector(1.0, 2.0);
}
}
}
It can be argued, that org.eclipse.draw2d.geometry.Vector.NULL
could be used. However, in this case the message is misleading.
Versions:
- SonarQube 8.9 LTS
- SonarLint 5.9