Home
Redundant pairs of parentheses should be removed
Description
This rule states that any redundant pairs of parentheses should be removed from PL/SQL code. This is to ensure that the code is written in a concise and clear manner, and to reduce the amount of unnecessary characters in the code. Redundant parentheses can be identified by looking for pairs of parentheses that are not necessary for the code to be syntactically correct. By removing these pairs of parentheses, the code will be easier to read and understand.
Key Benefits
- Redundancy: It eliminates unnecessary repetition and improves readability.
- Simplicity: It makes code simpler and easier to understand.
- Consistency: It helps maintain consistency across code bases.
- Performance: It can improve code performance.
Non-compliant Code Example
BEGIN
IF score > 70 THEN
DBMS_OUTPUT.PUT('Grade A');
ELSIF (((score > 50)) AND score < 70) THEN --Non compliant code (Condition with redundant parentheses)
DBMS_OUTPUT.PUT('Grade B');
ELSIF score > 35 AND score < 50 THEN
DBMS_OUTPUT.PUT('Grade C');
ELSE
DBMS_OUTPUT.PUT('Grade D');
END IF;
END;
Compliant Code Example
BEGIN
IF score > 70 THEN
DBMS_OUTPUT.PUT('Grade A');
ELSIF (score > 50 AND score < 70) THEN --Compliant code (Condition without redundant parentheses)
DBMS_OUTPUT.PUT('Grade B');
ELSIF score > 35 AND score < 50 THEN
DBMS_OUTPUT.PUT('Grade C');
ELSE
DBMS_OUTPUT.PUT('Grade D');
END IF;
END;