Skip to content

Commit 035aa2b

Browse files
highlight violating code lines in bad examples and fixes in good examples
1 parent b73fa07 commit 035aa2b

File tree

123 files changed

+262
-262
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+262
-262
lines changed

docs/4-language-usage/1-general/g-1010.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ It's a good alternative for comments to indicate the start and end of a named pr
99

1010
## Example (bad)
1111

12-
``` sql
12+
``` sql hl_lines="2 4 6 8"
1313
begin
1414
begin
1515
null;
@@ -24,7 +24,7 @@ end;
2424

2525
## Example (good)
2626

27-
``` sql
27+
``` sql hl_lines="2 5 7 10"
2828
begin
2929
<<prepare_data>>
3030
begin

docs/4-language-usage/1-general/g-1020.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Use a label directly in front of loops and nested anonymous blocks:
1212

1313
## Example (bad)
1414

15-
``` sql
15+
``` sql hl_lines="10 15 22 27 33"
1616
declare
1717
i integer;
1818
co_min_value constant integer := 1;
@@ -52,7 +52,7 @@ end;
5252

5353
## Example (good)
5454

55-
``` sql
55+
``` sql hl_lines="10 15 22 27 33"
5656
declare
5757
i integer;
5858
co_min_value constant integer := 1;

docs/4-language-usage/1-general/g-1030.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Unused variables decrease the maintainability and readability of your code.
99

1010
## Example (bad)
1111

12-
``` sql
12+
``` sql hl_lines="4 6"
1313
create or replace package body my_package is
1414
procedure my_proc is
1515
l_last_name employees.last_name%type;
@@ -33,7 +33,7 @@ end my_package;
3333

3434
## Example (good)
3535

36-
``` sql
36+
``` sql hl_lines="5 12"
3737
create or replace package body my_package is
3838
procedure my_proc is
3939
l_last_name employees.last_name%type;

docs/4-language-usage/1-general/g-1040.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Any part of your code, which is no longer used or cannot be reached, should be e
99

1010
## Example (bad)
1111

12-
``` sql
12+
``` sql hl_lines="4 12 19 31 38"
1313
declare
1414
co_dept_purchasing constant departments.department_id%type := 30;
1515
begin

docs/4-language-usage/1-general/g-1050.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ To avoid an extreme plethora of constants or false positives, a literal should n
1313

1414
## Example (bad)
1515

16-
``` sql
16+
``` sql hl_lines="2-4"
1717
begin
1818
some_api.setup(in_department_id => 10);
1919
some_api.process(in_department_id => 10);
@@ -24,7 +24,7 @@ end;
2424

2525
## Example (good)
2626

27-
``` sql
27+
``` sql hl_lines="7-9"
2828
create or replace package constants_up is
2929
co_dept_admin constant departments.department_id%type := 10;
3030
end constants_up;

docs/4-language-usage/1-general/g-1060.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Instead of using `rowid` for later reference to the original row one should use
1111

1212
## Example (bad)
1313

14-
``` sql
14+
``` sql hl_lines="6 11"
1515
begin
1616
insert into employees_log (
1717
employee_id

docs/4-language-usage/1-general/g-1070.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Having an end-of-comment within a block comment will end that block-comment. Thi
99

1010
## Example (bad)
1111

12-
``` sql
12+
``` sql hl_lines="2 4"
1313
begin
1414
/* comment one -- nested comment two */
1515
null;
@@ -21,7 +21,7 @@ end;
2121

2222
## Example (good)
2323

24-
``` sql
24+
``` sql hl_lines="2 4"
2525
begin
2626
/* comment one, comment two */
2727
null;

docs/4-language-usage/1-general/g-1080.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This rule ignores operators `+`, `*` and `||`, and expressions: `1=1`, `1<>1`, `
1111

1212
## Example (bad)
1313

14-
``` sql
14+
``` sql hl_lines="9 10"
1515
declare
1616
co_max_salary constant emp.salary%type := 3000;
1717
begin
@@ -29,7 +29,7 @@ end;
2929

3030
## Example (good)
3131

32-
``` sql
32+
``` sql hl_lines="9"
3333
declare
3434
co_max_salary constant emp.salary%type := 3000;
3535
begin

docs/4-language-usage/2-variables-and-types/1-general/g-2110.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Changing the size of the database column last_name in the employees table from `
99

1010
## Example (bad)
1111

12-
``` sql
12+
``` sql hl_lines="3"
1313
create or replace package body my_package is
1414
procedure my_proc is
1515
l_last_name varchar2(20 char);
@@ -31,7 +31,7 @@ end my_package;
3131

3232
## Example (good)
3333

34-
``` sql
34+
``` sql hl_lines="3"
3535
create or replace package body my_package is
3636
procedure my_proc is
3737
l_last_name employees.last_name%type;

docs/4-language-usage/2-variables-and-types/1-general/g-2120.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ A single location could be either a type specification package or the database (
1111

1212
## Example (bad)
1313

14-
``` sql
14+
``` sql hl_lines="3"
1515
create or replace package body my_package is
1616
procedure my_proc is
1717
subtype big_string_type is varchar2(1000 char);
@@ -26,7 +26,7 @@ end my_package;
2626

2727
## Example (good)
2828

29-
``` sql
29+
``` sql hl_lines="8"
3030
create or replace package types_up is
3131
subtype big_string_type is varchar2(1000 char);
3232
end types_up;

docs/4-language-usage/2-variables-and-types/1-general/g-2130.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Type | Usage
2020

2121
## Example (bad)
2222

23-
``` sql
23+
``` sql hl_lines="3"
2424
create or replace package body my_package is
2525
procedure my_proc is
2626
l_note varchar2(1000 char);
@@ -34,7 +34,7 @@ end my_package;
3434

3535
## Example (good)
3636

37-
``` sql
37+
``` sql hl_lines="8"
3838
create or replace package types_up is
3939
subtype big_string_type is varchar2(1000 char);
4040
end types_up;

docs/4-language-usage/2-variables-and-types/1-general/g-2135.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Expending resources calculating and assigning values to a local variable and nev
99

1010
## Example (bad)
1111

12-
``` sql
12+
``` sql hl_lines="13"
1313
create or replace package body my_package is
1414
procedure my_proc is
1515
co_employee_id constant employees.employee_id%type := 1042;
@@ -35,7 +35,7 @@ end my_package;
3535

3636
## Example (good)
3737

38-
``` sql
38+
``` sql hl_lines="13 15"
3939
create or replace package body my_package is
4040
procedure my_proc is
4141
co_employee_id constant employees.employee_id%type := 1042;

docs/4-language-usage/2-variables-and-types/1-general/g-2140.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Variables are initialized to `null` by default.
99

1010
## Example (bad)
1111

12-
``` sql
12+
``` sql hl_lines="2"
1313
declare
1414
l_note big_string_type := null;
1515
begin
@@ -20,7 +20,7 @@ end;
2020

2121
## Example (good)
2222

23-
``` sql
23+
``` sql hl_lines="2"
2424
declare
2525
l_note big_string_type;
2626
begin

docs/4-language-usage/2-variables-and-types/1-general/g-2145.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ There is no reason to assign a variable to itself. It is either a redundant stat
99

1010
## Example (bad)
1111

12-
``` sql
12+
``` sql hl_lines="8"
1313
declare
1414
co_parallel_degree constant types_up.name%type := 'parallel_degree';
1515
l_function_result pls_integer;
@@ -26,7 +26,7 @@ end;
2626

2727
## Example (good)
2828

29-
``` sql
29+
``` sql hl_lines="8"
3030
declare
3131
co_parallel_degree constant types_up.name%type := 'parallel_degree';
3232
l_function_result pls_integer;

docs/4-language-usage/2-variables-and-types/1-general/g-2150.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ The `null` value can cause confusion both from the standpoint of code review and
99

1010
## Example (bad)
1111

12-
``` sql
12+
``` sql hl_lines="4"
1313
declare
1414
l_value integer;
1515
begin
@@ -22,7 +22,7 @@ end;
2222

2323
## Example (good)
2424

25-
``` sql
25+
``` sql hl_lines="4"
2626
declare
2727
l_value integer;
2828
begin

docs/4-language-usage/2-variables-and-types/1-general/g-2160.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ If your initialization fails, you will not be able to handle the error in your e
99

1010
## Example (bad)
1111

12-
``` sql
12+
``` sql hl_lines="3 4"
1313
declare
1414
co_department_id constant integer := 100;
1515
l_department_name departments.department_name%type :=
@@ -22,7 +22,7 @@ end;
2222

2323
## Example (good)
2424

25-
``` sql
25+
``` sql hl_lines="8"
2626
declare
2727
co_department_id constant integer := 100;
2828
co_unkown_name constant departments.department_name%type := 'unknown';

docs/4-language-usage/2-variables-and-types/1-general/g-2170.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ The readability of your code will be higher when you do not overload variables.
99

1010
## Example (bad)
1111

12-
``` sql
12+
``` sql hl_lines="7 11"
1313
begin
1414
<<main>>
1515
declare
@@ -33,7 +33,7 @@ end;
3333

3434
## Example (good)
3535

36-
``` sql
36+
``` sql hl_lines="7 11"
3737
begin
3838
<<main>>
3939
declare

docs/4-language-usage/2-variables-and-types/1-general/g-2180.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Quoted identifiers make your code hard to read and maintain.
99

1010
## Example (bad)
1111

12-
``` sql
12+
``` sql hl_lines="2-4"
1313
declare
1414
"sal+comm" integer; -- violates also naming conventions (G-9102)
1515
"my constant" constant integer := 1; -- violates also naming conventions (G-9114)
@@ -26,7 +26,7 @@ end;
2626

2727
## Example (good)
2828

29-
``` sql
29+
``` sql hl_lines="2-4"
3030
declare
3131
l_sal_comm integer;
3232
co_my_constant constant integer := 1;

docs/4-language-usage/2-variables-and-types/1-general/g-2185.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ You should ensure that the name you have chosen well defines its purpose and usa
99

1010
## Example (bad)
1111

12-
``` sql
12+
``` sql hl_lines="2-4"
1313
declare
1414
i integer;
1515
c constant integer := 1; -- violates also naming conventions (G-9114)
@@ -26,7 +26,7 @@ end;
2626

2727
## Example (good)
2828

29-
``` sql
29+
``` sql hl_lines="2-4"
3030
declare
3131
l_sal_comm integer;
3232
co_my_constant constant integer := 1;

docs/4-language-usage/2-variables-and-types/1-general/g-2190.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Use of `rowid` or `urowid` means that your SQL statement will not be portable to
1111

1212
## Example (bad)
1313

14-
``` sql
14+
``` sql hl_lines="7"
1515
declare
1616
l_department_name departments.department_name%type;
1717
l_rowid rowid;
@@ -25,7 +25,7 @@ end;
2525

2626
## Example (good)
2727

28-
``` sql
28+
``` sql hl_lines="7"
2929
declare
3030
l_department_name departments.department_name%type;
3131
l_department_id departments.department_id%type;

docs/4-language-usage/2-variables-and-types/2-numeric-data-types/g-2210.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ If you do not specify precision `number` is defaulted to 38 or the maximum suppo
99

1010
## Example (bad)
1111

12-
``` sql
12+
``` sql hl_lines="2"
1313
create or replace package types_up is
1414
subtype salary_type is number;
1515
end types_up;
@@ -18,7 +18,7 @@ end types_up;
1818

1919
## Example (good)
2020

21-
``` sql
21+
``` sql hl_lines="2"
2222
create or replace package types_up is
2323
subtype salary_type is number(5,1);
2424
end types_up;

docs/4-language-usage/2-variables-and-types/2-numeric-data-types/g-2220.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ There are many reasons to use `pls_integer` instead of `number`:
1414

1515
## Example (bad)
1616

17-
``` sql
17+
``` sql hl_lines="2"
1818
declare
1919
l_result number(9,0) := 0; -- violates also G-2130, G-2230
2020
co_upper_bound constant pls_integer := 1e8;
@@ -33,7 +33,7 @@ end;
3333

3434
## Example (good)
3535

36-
``` sql
36+
``` sql hl_lines="2"
3737
declare
3838
l_result pls_integer := 0;
3939
co_upper_bound constant pls_integer := 1e8;

docs/4-language-usage/2-variables-and-types/2-numeric-data-types/g-2230.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ With Oracle Database 11g, the new data type `simple_integer` has been introduced
1212

1313
## Example (bad)
1414

15-
``` sql
15+
``` sql hl_lines="2"
1616
declare
1717
l_result number(9,0) := 0; -- violates also G-2130, G-2220
1818
co_upper_bound constant pls_integer := 1e8;
@@ -31,7 +31,7 @@ end;
3131

3232
## Example (good)
3333

34-
``` sql
34+
``` sql hl_lines="2"
3535
declare
3636
l_result simple_integer := 0;
3737
co_upper_bound constant pls_integer := 1e8;

0 commit comments

Comments
 (0)