Home

Redundant pairs of parentheses should be removed

Description

    The PowerBuilder code rule "Redundant pairs of parentheses should be removed" means that when writing PowerBuilder code, any redundant pairs of parentheses should be removed as they are not necessary and can make the code difficult to read and understand. Redundant parentheses can be removed by replacing them with a single set of parentheses or by simply removing them altogether. This rule helps to ensure that the code is well-structured and easier to read.

Key Benefits

  • Improved readability: Removing redundant pairs of parentheses can help make code easier to read and understand.
  • Reduced complexity: Removing redundant pairs of parentheses can help reduce the complexity of the code, making it simpler to maintain.
  • Fewer errors: Removing redundant pairs of parentheses can help reduce the chances of coding errors.

 

Non-compliant Code Example

function string TestFunctionCall (string cnt)

int @count  = ((3 + 1)); //Non compliant code

int x;
int y;

IF (x > 0) AND ((x+y > 0))  THEN //Non compliant code
	messagebox('Success','(x > 0) AND ((x+y > 0))') 
ELSEIF  ((x+y > 0)) THEN //Non compliant code
	messagebox('Success','((x+y > 0))') //Non compliant code
ELSEIF  (x > 0) OR ((x+y > 0)) THEN //Non compliant code
	messagebox('Success','(x > 0) OR ((x+y > 0))')
ELSE
	messagebox('Failed','select at least one ')
END IF;

return cnt

end function

Compliant Code Example

function string TestFunctionCall (string cnt)

cnt  = (3 + 1); //Compliant code 

return cnt

end function
Visual Expert 2024
 VEPBRULE51