53 lines
1.4 KiB
Plaintext
53 lines
1.4 KiB
Plaintext
``++BEGIN...END++`` can be omitted from a one-line block, such as with an ``++IF++`` statement or ``++WHILE++`` loop, but doing so can be misleading and induce bugs.
|
|
|
|
|
|
This rule raises an issue when the indentation of the lines after a one-line block indicates an intent to include those lines in the block, but the omission of ``++BEGIN...END++`` means the lines will be unconditionally executed once.
|
|
|
|
|
|
Note that this rule considers tab characters to be equivalent to 1 space. If you mix spaces and tabs you will sometimes see issues in code which looks fine in your editor but is confusing when you change the size of tabs.
|
|
|
|
== Noncompliant Code Example
|
|
|
|
[source,sql]
|
|
----
|
|
IF (0=1)
|
|
EXEC firstActionInBlock;
|
|
EXEC secondAction; -- Noncompliant; executed unconditionally
|
|
EXEC thirdAction;
|
|
|
|
IF (0=1) EXEC firstActionInBlock; EXEC secondAction; -- Noncompliant; secondAction executed unconditionally
|
|
|
|
IF (0=1) EXEC firstActionInBlock; -- Noncompliant
|
|
EXEC secondAction; -- Executed unconditionally
|
|
----
|
|
|
|
== Compliant Solution
|
|
|
|
[source,sql]
|
|
----
|
|
IF (0=1) BEGIN
|
|
EXEC firstActionInBlock;
|
|
EXEC secondAction;
|
|
END
|
|
EXEC thirdAction;
|
|
----
|
|
|
|
include::../see.adoc[]
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
include::../message.adoc[]
|
|
|
|
include::../highlighting.adoc[]
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
include::../comments-and-links.adoc[]
|
|
endif::env-github,rspecator-view[]
|