Home
Return of boolean expressions should not be wrapped into an if-then-else statement
Description
This PowerBuilder code rule states that boolean expressions should not be wrapped in an if-then-else statement. This means that when a boolean expression is used, the code should not be written in a way that requires an if-then-else statement to be used. The code should instead be written in a way that the boolean expression can be evaluated directly without the need for an if-then-else statement.
Key Benefits
- Simplicity: Return of boolean expressions should not be wrapped into an if-then-else statement rule provides a simple and straightforward way to evaluate boolean expressions.
- Efficiency: This rule helps to reduce the number of lines of code, thus increasing the efficiency of the program.
- Readability: This rule helps to make the code more readable and understandable.
- Maintainability: This rule helps to ensure that the code is maintainable and can be easily modified in the future.
Non-compliant Code Example
function string TestFunctionCall (string cnt, boolean exp )
if exp then //Non compliant code
return true;
else
return false;
end if
end function
Compliant Code Example
function string TestFunctionCall (boolean exp )
return exp; //Compliant code
end function