-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix # 50 - Added new rule G-4325: Never reuse labels in inner scopes.
- Loading branch information
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
docs/4-language-usage/4-control-structures/3-flow-control/g-4325.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# G-4325: Never reuse labels in inner scopes. | ||
|
||
!!! warning "Major" | ||
Maintainability, Reliability, Testability | ||
|
||
## Reason | ||
|
||
Reusing labels inside the scope of another label with the same name leads to confusion, less chance of understanding the code, and could lead to bugs (for example if using `exit my_label` exits at a different nesting level than expected.) | ||
|
||
## Example (bad) | ||
|
||
``` sql | ||
<<my_label>> | ||
declare | ||
co_min_value constant simple_integer := 1; | ||
co_max_value constant simple_integer := 8; | ||
begin | ||
<<my_label>> | ||
for i in co_min_value..co_max_value | ||
loop | ||
sys.dbms_output.put_line(i); | ||
end loop; | ||
end; | ||
/ | ||
``` | ||
|
||
## Example (good) | ||
|
||
``` sql | ||
<<output_values>> | ||
declare | ||
co_min_value constant simple_integer := 1; | ||
co_max_value constant simple_integer := 8; | ||
begin | ||
<<process_values>> | ||
for i in co_min_value..co_max_value | ||
loop | ||
sys.dbms_output.put_line(i); | ||
end loop process_values; | ||
end output_values; | ||
/ | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4baf7e3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix #50