rspec/rules/S4280/plsql/rule.adoc

39 lines
664 B
Plaintext
Raw Normal View History

2021-04-28 16:49:39 +02:00
Using the same name for multiple purposes reduces the understandability of the code and might eventually lead to bugs.
This rule verifies that no label is reused in an inner scope.
== Noncompliant Code Example
----
<<foo>>
DECLARE
a CONSTANT PLS_INTEGER := 0;
BEGIN
<<foo>> -- Noncompliant
DECLARE
b CONSTANT PLS_INTEGER := 42;
BEGIN
DBMS_OUTPUT.PUT_LINE('x = ' || foo.b); -- Confusing
END;
END;
/
----
== Compliant Solution
----
<<foo>>
DECLARE
a CONSTANT PLS_INTEGER := 0;
BEGIN
<<bar>>
DECLARE
b CONSTANT PLS_INTEGER := 42;
BEGIN
DBMS_OUTPUT.PUT_LINE('x = ' || bar.b);
END;
END;
/
----