rspec/rules/S3973/tsql/rule.adoc

56 lines
1.1 KiB
Plaintext
Raw Normal View History

2021-01-27 13:42:22 +01:00
In the absence of enclosing ``++BEGIN...END++`` block, the line immediately after a conditional is the one that is conditionally executed. By both convention and good practice, such lines are indented. In the absence of both ``++BEGIN...END++`` block and indentation the intent of the original programmer is entirely unclear and perhaps not actually what is executed. Additionally, such code is highly likely to be confusing to maintainers.
2020-06-30 12:48:39 +02:00
== Noncompliant Code Example
2022-02-04 17:28:24 +01:00
[source,sql]
2020-06-30 12:48:39 +02:00
----
IF @condition -- Noncompliant
EXEC doTheThing;
EXEC doTheOtherThing;
EXEX somethingElseEntirely;
EXEC foo;
----
== Compliant Solution
2022-02-04 17:28:24 +01:00
[source,sql]
2020-06-30 12:48:39 +02:00
----
IF @condition
BEGIN
EXEC doTheThing;
EXEC doTheOtherThing;
EXEX somethingElseEntirely;
END;
EXEC foo;
----
Or
2022-02-04 17:28:24 +01:00
[source,sql]
2020-06-30 12:48:39 +02:00
----
IF @condition
EXEC doTheThing;
EXEC doTheOtherThing;
EXEX somethingElseEntirely;
EXEC foo;
----
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[]