22 lines
272 B
Plaintext
22 lines
272 B
Plaintext
![]() |
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
|
||
|
|
||
|
----
|
||
|
if (var == null) {
|
||
|
return null;
|
||
|
}
|
||
|
return var;
|
||
|
}
|
||
|
----
|
||
|
|
||
|
|
||
|
== Compliant Solution
|
||
|
|
||
|
----
|
||
|
return var;
|
||
|
}
|
||
|
----
|
||
|
|