Home

Boolean literals should not be redundant

Description

    The "Boolean literals should not be redundant" rule states that when writing PowerBuilder code, Boolean literals (true/false) should not be used redundantly. This means that if a Boolean value is already established, it should not be repeated unnecessarily. For example, if a Boolean value has already been set to "true," it should not be written again as "true" in the same code.

Key Benefits

  • Prevent redundancy : Helps to prevent redundant Boolean literals in code.
  • Improve readability : Enhances the readability of code by avoiding unnecessary Boolean literals.
  • Optimization : Optimizes the code by avoiding unnecessary Boolean literals.

 

Non-compliant Code Example

function string TestFunctionCall (BOOLEAN isValid)

BOOLEAN flag = true;

if flag = False then //Non compliant code
	messagebox('is false')
end if

if isValid = True then //Non compliant code
	messagebox('is true')
end if

if Not isValid then
	messagebox('not')
end if

return "

end function

Compliant Code Example

function string TestFunctionCall (BOOLEAN isValid)

BOOLEAN flag = true;

if Not flag then //Compliant code
	messagebox('is false')
end if

if isValid then //Compliant code
	messagebox('is true')
end if

if Not isValid then
	messagebox('not')
end if

return "

end function
Visual Expert 2024
 VEPBRULE61