rspec/rules/S2476/plsql/rule.adoc
Fred Tingaud 16f6c0aecf
Inline adoc when include has no additional value (#1940)
Inline adoc files when they are included exactly once.

Also fix language tags because this inlining gives us better information
on what language the code is written in.
2023-05-25 14:18:12 +02:00

82 lines
1.2 KiB
Plaintext

== Why is this an issue?
Labeled loops are useful, especially when the code is badly indented, to match the begin and end of each loop. This rule verifies that loop start and end labels match, when both are specified.
=== Noncompliant code example
[source,sql]
----
BEGIN
LOOP
EXIT;
END LOOP; -- Compliant, this loop has no label at all
<<myLoopLabel1>>
LOOP
EXIT;
END LOOP; -- Compliant, this loop only has a start label
LOOP
EXIT;
END LOOP myLoopLabel2; -- Compliant, this loop only has an end label
<<myLoopLabel4>>
LOOP
EXIT;
END LOOP myLoopLabel5; -- Noncompliant, label mismatch
<<myLoopLabel6>>
<<myLoopLabel7>>
LOOP
EXIT;
END LOOP myLoopLabel7; -- Noncompliant, several start labels mismatch
END;
/
----
=== Compliant solution
[source,sql]
----
BEGIN
LOOP
EXIT;
END LOOP;
<<myLoopLabel1>>
LOOP
EXIT;
END LOOP;
LOOP
EXIT;
END LOOP myLoopLabel2;
<<myLoopLabel4>>
LOOP
EXIT;
END LOOP myLoopLabel4;
<<myLoopLabel7>>
LOOP
EXIT;
END LOOP myLoopLabel7;
END;
/
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Change this label to "xxx".
endif::env-github,rspecator-view[]