org.sonar.l10n.java.rules.squid.S2225.html Maven / Gradle / Ivy
The newest version!
Calling toString()
or clone()
on an object should always return a string or an object. Returning null
instead contravenes the method's implicit contract.
Noncompliant Code Example
public override string ToString () {
if (this.collection.Count == 0) {
return null; // Noncompliant
} else {
// ...
Compliant Solution
public override string ToString () {
if (this.collection.Count == 0) {
return "";
} else {
// ...
See
- MITRE CWE-476 : NULL Pointer Dereference
© 2015 - 2025 Weber Informatics LLC | Privacy Policy