rspec/rules/S3972/tsql/rule.adoc

56 lines
1.1 KiB
Plaintext
Raw Normal View History

== Why is this an issue?
When an `IF` is placed on the same line as the closing `END` from a preceding `IF`, `ELSE` or `ELSE IF` part, it is either an error - `ELSE` is missing - or the invitation to a future error as maintainers fail to understand that the two statements are unconnected.
2020-06-30 12:48:39 +02:00
This code is confusing
2020-06-30 12:48:39 +02:00
2022-02-04 17:28:24 +01:00
[source,sql]
2020-06-30 12:48:39 +02:00
----
IF (condition1) BEGIN
EXEC something
END IF (condition2) BEGIN -- Noncompliant
EXEC something
END
----
Either the two conditions are unrelated and they should be visually separated
2020-06-30 12:48:39 +02:00
2022-02-04 17:28:24 +01:00
[source,sql]
2020-06-30 12:48:39 +02:00
----
IF (condition1) BEGIN
EXEC something
END
IF (condition2) BEGIN
2020-06-30 12:48:39 +02:00
EXEC something
END
----
Or they were supposed to be exclusive and you should use `ELSE IF` instead
2022-02-04 17:28:24 +01:00
[source,sql]
2020-06-30 12:48:39 +02:00
----
IF (condition1) BEGIN
EXEC something
END ELSE IF (condition2) BEGIN
2020-06-30 12:48:39 +02:00
EXEC something
END
----
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[]