rspec/rules/S909/plsql/rule.adoc
Fred Tingaud 51369b610e
Make sure that includes are always surrounded by empty lines (#2270)
When an include is not surrounded by empty lines, its content is inlined
on the same line as the adjacent content. That can lead to broken tags
and other display issues.
This PR fixes all such includes and introduces a validation step that
forbids introducing the same problem again.
2023-06-22 10:38:01 +02:00

69 lines
1.5 KiB
Plaintext

== Why is this an issue?
FOR and WHILE loops are structured control flow statements.
A FOR loop will iterate once for each element in the range, and the WHILE iterates for as long as a condition holds.
However, inserting an ``++EXIT++`` statement within the loop breaks this structure, reducing the code's readability and making it harder to debug.
=== Noncompliant code example
[source,sql]
----
SET SERVEROUTPUT ON
DECLARE
TYPE myCollectionType IS VARRAY(10) OF VARCHAR2(42);
myCollection myCollectionType := myCollectionType('Foo', 'Bar', NULL, 'Baz', 'Qux');
i PLS_INTEGER;
BEGIN
i := 1;
WHILE i <= myCollection.LAST LOOP
EXIT WHEN myCollection(i) IS NULL; -- Noncompliant, breaks the structure of the WHILE
DBMS_OUTPUT.PUT_LINE('Got: ' || myCollection(i));
i := i + 1;
END LOOP;
----
=== Compliant solution
[source,sql]
----
SET SERVEROUTPUT ON
DECLARE
TYPE myCollectionType IS VARRAY(10) OF VARCHAR2(42);
myCollection myCollectionType := myCollectionType('Foo', 'Bar', NULL, 'Baz', 'Qux');
i PLS_INTEGER;
BEGIN
i := 1;
WHILE i <= myCollection.LAST AND myCollection(i) IS NOT NULL LOOP
DBMS_OUTPUT.PUT_LINE('Got: ' || myCollection(i));
i := i + 1;
END LOOP;
END;
/
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Remove this use of "EXIT".
'''
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]