All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.l10n.java.rules.squid.S2225.html Maven / Gradle / Ivy

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





© 2015 - 2025 Weber Informatics LLC | Privacy Policy