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

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

There is a newer version: 8.9.0.37768
Show newest version

There's no point in forcing the overhead of a method call for a method that always returns the same constant value. Even worse, the fact that a method call must be made will likely mislead developers who call the method into thinking that something more is done. Declare a constant instead.

Noncompliant Code Example

public int getBestNumber() {
return 12;  // Noncompliant
}

Compliant Solution

public static int bestNumber = 12;

Exceptions

@Override methods are ignored by this rule, since they may be required by an interface or needed to replace the value returned by a parent class.





© 2015 - 2025 Weber Informatics LLC | Privacy Policy