
Co-authored-by: Amélie Renard <44666826+amelie-renard-sonarsource@users.noreply.github.com>
48 lines
1.4 KiB
Plaintext
48 lines
1.4 KiB
Plaintext
== Why is this an issue?
|
|
|
|
Having inconsistent indentation and omitting `BEGIN...END` from a control structure, such as an `IF` statement or `WHILE` loop, is misleading and can induce bugs.
|
|
|
|
This rule raises an issue when the indentation of the lines after a control structure indicates an intent to include those lines in the block, but the omission of `BEGIN...END` means the lines will be unconditionally executed once.
|
|
|
|
The following patterns are recognized:
|
|
|
|
[source,sql]
|
|
----
|
|
IF (0=1)
|
|
EXEC firstActionInBlock;
|
|
EXEC secondAction; -- Noncompliant: secondAction is executed unconditionally
|
|
EXEC thirdAction;
|
|
----
|
|
|
|
[source,sql]
|
|
----
|
|
IF (0=1) EXEC firstActionInBlock; EXEC secondAction; -- Noncompliant: secondAction is executed unconditionally
|
|
----
|
|
|
|
[source,sql]
|
|
----
|
|
IF (0=1) EXEC firstActionInBlock;
|
|
EXEC secondAction; -- Noncompliant: secondAction is executed unconditionally
|
|
----
|
|
|
|
Note that this rule considers tab characters to be equivalent to 1 space. When mixing spaces and tabs, a code may look fine in one editor but be confusing in another configured differently.
|
|
|
|
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[]
|