== Why is this an issue?

Labeled blocks are useful to help maintainers match-up the beginning and ending of each section of code, especially when that code is badly indented. However, if used, those labels must appear on the same line as the "END" keyword in order to avoid confusion. Otherwise, the label might be misread by maintainers as a procedure call.


=== Noncompliant code example

[source,sql]
----
SET SERVEROUTPUT ON

DECLARE
  PROCEDURE foo AS
  BEGIN
    DBMS_OUTPUT.PUT_LINE('foo was called!');
  END;
BEGIN
  BEGIN
    NULL;
  END -- Semicolon was forgotten?

  foo; -- Noncompliant; looks like a procedure call, but is actually END block label

  <<myBlockLabel>>
  BEGIN
    NULL;
  END 
  myBlockLabel; -- Noncompliant
END;
/
----


=== Compliant solution

[source,sql]
----
SET SERVEROUTPUT ON

DECLARE
  PROCEDURE foo AS
  BEGIN
    DBMS_OUTPUT.PUT_LINE('foo was called!');
  END;
BEGIN
  BEGIN
    NULL;
  END; 

  foo; -- The method "foo" was actually meant to be called

  <<myBlockLabel>>
  BEGIN
    NULL;
  END myBlockLabel;
END;
/
----


ifdef::env-github,rspecator-view[]

'''
== Implementation Specification
(visible only on this page)

=== Message

To prevent confusion between labels and procedure calls, the semicolon should be moved to line n.


'''
== Comments And Links
(visible only on this page)

=== on 28 Jan 2015, 19:06:53 Ann Campbell wrote:
\[~dinesh.bolkensteyn] please take a look at this description, which is copied from Nemo. It doesn't quite make sense to me & reads as a hasty copy/paste of a related rule. 

=== on 8 May 2015, 15:27:04 Dinesh Bolkensteyn wrote:
\[~ann.campbell.2] The noncompliant ``++foo;++`` can be seen as a ``++foo++`` procedure call. However, it actually is the label of the previous ``++BEGIN .. END++`` block, because the ``++END++`` was not terminated by a semicolon.


This could potentially reveal a bug in the code.


To avoid any confusion, the label should be on the same line as the ``++END++``

=== on 8 May 2015, 17:48:54 Ann Campbell wrote:
Here's my confusion, [~dinesh.bolkensteyn]: the title is about semicolons and the description is about what line the end-block label is on. So... which should change?


Also, I've updated the code samples a little. Please look them over again.

=== on 11 May 2015, 09:07:24 Dinesh Bolkensteyn wrote:
Make a suggestion [~ann.campbell.2] - i think the title could be something like ``++Block "END" and semicolon ";" should be on the same line++``

=== on 11 May 2015, 09:10:02 Dinesh Bolkensteyn wrote:
I've slightly updated the descriptions again [~ann.campbell.2] - I think it now should make sense

=== on 11 May 2015, 13:45:22 Ann Campbell wrote:
\[~dinesh.bolkensteyn] I gave up and tested this rule against the Noncompliant example to verify where the issue would be marked. I've updated the rule based on that. Please double-check me.

=== on 11 May 2015, 14:09:55 Dinesh Bolkensteyn wrote:
Perfect

endif::env-github,rspecator-view[]
