26 lines
328 B
Plaintext
26 lines
328 B
Plaintext
== Why is this an issue?
|
|
|
|
It is simpler and clearer to return a variable than it is to test the variable and then return its value as a literal.
|
|
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,text]
|
|
----
|
|
if (var == null) {
|
|
return null;
|
|
}
|
|
return var;
|
|
}
|
|
----
|
|
|
|
|
|
=== Compliant solution
|
|
|
|
[source,text]
|
|
----
|
|
return var;
|
|
}
|
|
----
|
|
|