Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Feature/issue 111 formatter #119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 26 commits into from
Jul 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
c40a39c
add formatter settings
PhilippSalvisberg Oct 10, 2021
f8da164
Whitespace: After commas (unchecked)
PhilippSalvisberg Oct 10, 2021
546660c
enforced formatter call for all .md files
PhilippSalvisberg Oct 10, 2021
a17b8e5
include fix from Trivadis/plsql-formatter-settings#152
PhilippSalvisberg Oct 12, 2021
2516c8d
Formatter after fix for Trivadis/plsql-formatter-settings#152
PhilippSalvisberg Oct 12, 2021
c6074c0
restore original decode format and suppress formatter changes
PhilippSalvisberg Oct 12, 2021
875fb1b
use newest standalone formatter based on SQLcl 21.3.3
PhilippSalvisberg Dec 15, 2021
c7d39df
change info to error message in pre-commit hook
PhilippSalvisberg Dec 15, 2021
0341e5e
update Arbori program based on commit 715ae6761195132c4a766969466135d…
PhilippSalvisberg Dec 15, 2021
7fce52a
formatting result based on latest configuration
PhilippSalvisberg Dec 15, 2021
4357c3a
back to version 21.2.1 of tvdformat.jar
PhilippSalvisberg Dec 17, 2021
d02ac8c
ignore VSCode project files
PhilippSalvisberg Dec 26, 2021
58f517b
use tvdformat.jar 21.4.1
PhilippSalvisberg Dec 26, 2021
b463e0f
custom format based on sqldev-21.4.1
PhilippSalvisberg Dec 26, 2021
c3a9a4e
use tvdformat.jar 21.4.2
PhilippSalvisberg Jan 29, 2022
11ffaaf
custom format based on sqldev-21.4.2
PhilippSalvisberg Jan 29, 2022
41b1ac2
custom format based on sqldev-21.4.3
PhilippSalvisberg Apr 3, 2022
a56ca52
use tvdformat.jar 21.4.3
PhilippSalvisberg Apr 3, 2022
f5f09fc
formatting result based on latest configuration
PhilippSalvisberg Apr 3, 2022
ec67705
update custom format, snapshot version of 22.1.0
PhilippSalvisberg Apr 3, 2022
9ed71a4
formatting result based on latest configuration
PhilippSalvisberg Apr 3, 2022
583683f
update formatter to sqldev-22.2.0
PhilippSalvisberg Jul 8, 2022
ec6495f
add fix of trivadis/plsql-formatter-settings#214
PhilippSalvisberg Jul 8, 2022
d40785d
formatter changes due to lastest formatter and formatter settings
PhilippSalvisberg Jul 8, 2022
fc41e20
create git hooks directory if necessary
PhilippSalvisberg Jul 13, 2022
9531eca
update formatter Arbori program to latest version
PhilippSalvisberg Jul 13, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions 3 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@

# temporary files
~$SQL-and-SQL-Coding-Guidelines.doc

# Visual Studio Code project folder
.vscode
14 changes: 7 additions & 7 deletions 14 docs/3-coding-style/coding-style.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,24 @@ Rule | Description

``` sql
procedure set_salary(in_employee_id in employees.employee_id%type) is
cursor c_employees(p_employee_id in employees.employee_id%type) is
cursor c_employees(p_employee_id in employees.employee_id%type) is
select last_name
,first_name
,salary
from employees
where employee_id = p_employee_id
order by last_name
,first_name;
,first_name;

r_employee c_employees%rowtype;
l_new_salary employees.salary%type;
r_employee c_employees%rowtype;
l_new_salary employees.salary%type;
begin
open c_employees(p_employee_id => in_employee_id);
open c_employees(p_employee_id => in_employee_id);
fetch c_employees into r_employee;
close c_employees;

new_salary (in_employee_id => in_employee_id
,out_salary => l_new_salary);
new_salary(in_employee_id => in_employee_id
,out_salary => l_new_salary);

-- Check whether salary has changed
if r_employee.salary <> l_new_salary then
Expand Down
4 changes: 2 additions & 2 deletions 4 docs/4-language-usage/1-general/g-1010.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ It's a good alternative for comments to indicate the start and end of a named pr

``` sql
begin
begin
begin
null;
end;

Expand All @@ -27,7 +27,7 @@ end;
``` sql
begin
<<prepare_data>>
begin
begin
null;
end prepare_data;

Expand Down
30 changes: 15 additions & 15 deletions 30 docs/4-language-usage/1-general/g-1020.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ Use a label directly in front of loops and nested anonymous blocks:

``` sql
declare
i integer;
i integer;
co_min_value constant integer := 1;
co_max_value constant integer := 10;
co_increment constant integer := 1;
begin
<<prepare_data>>
begin
begin
null;
end;

Expand All @@ -31,19 +31,19 @@ begin

i := co_min_value;
<<while_loop>>
while (i <= co_max_value)
loop
i := i + co_increment;
while (i <= co_max_value)
loop
i := i + co_increment;
end loop;

<<basic_loop>>
loop
loop
exit basic_loop;
end loop;

<<for_loop>>
for i in co_min_value..co_max_value
loop
loop
sys.dbms_output.put_line(i);
end loop;
end;
Expand All @@ -54,13 +54,13 @@ end;

``` sql
declare
i integer;
i integer;
co_min_value constant integer := 1;
co_max_value constant integer := 10;
co_increment constant integer := 1;
begin
<<prepare_data>>
begin
begin
null;
end prepare_data;

Expand All @@ -71,20 +71,20 @@ begin

i := co_min_value;
<<while_loop>>
while (i <= co_max_value)
loop
i := i + co_increment;
while (i <= co_max_value)
loop
i := i + co_increment;
end loop while_loop;

<<basic_loop>>
loop
loop
exit basic_loop;
end loop basic_loop;

<<for_loop>>
for i in co_min_value..co_max_value
loop
sys.dbms_output.put_line(i);
loop
sys.dbms_output.put_line(i);
end loop for_loop;
end;
/
Expand Down
22 changes: 13 additions & 9 deletions 22 docs/4-language-usage/1-general/g-1030.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,20 @@ Unused variables decrease the maintainability and readability of your code.
``` sql
create or replace package body my_package is
procedure my_proc is
l_last_name employees.last_name%type;
l_first_name employees.first_name%type;
l_last_name employees.last_name%type;
l_first_name employees.first_name%type;
co_department_id constant departments.department_id%type := 10;
e_good exception;
e_good exception;
begin
select e.last_name
into l_last_name
from employees e
where e.department_id = co_department_id;
exception
when no_data_found then null; -- handle_no_data_found;
when too_many_rows then null; -- handle_too_many_rows;
when no_data_found then
null; -- handle_no_data_found;
when too_many_rows then
null; -- handle_too_many_rows;
end my_proc;
end my_package;
/
Expand All @@ -34,9 +36,9 @@ end my_package;
``` sql
create or replace package body my_package is
procedure my_proc is
l_last_name employees.last_name%type;
l_last_name employees.last_name%type;
co_department_id constant departments.department_id%type := 10;
e_good exception;
e_good exception;
begin
select e.last_name
into l_last_name
Expand All @@ -45,8 +47,10 @@ create or replace package body my_package is

raise e_good;
exception
when no_data_found then null; -- handle_no_data_found;
when too_many_rows then null; -- handle_too_many_rows;
when no_data_found then
null; -- handle_no_data_found;
when too_many_rows then
null; -- handle_too_many_rows;
end my_proc;
end my_package;
/
Expand Down
38 changes: 21 additions & 17 deletions 38 docs/4-language-usage/1-general/g-1040.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,40 @@ Any part of your code, which is no longer used or cannot be reached, should be e
declare
co_dept_purchasing constant departments.department_id%type := 30;
begin
if 2=3 then
if 2 = 3 then
null; -- some dead code here
end if;

null; -- some enabled code here

<<my_loop>>
loop
exit my_loop;
exit my_loop;
null; -- some dead code here
end loop my_loop;

null; -- some other enabled code here

case
case
when 1 = 1 and 'x' = 'y' then
null; -- some dead code here
else
null; -- some further enabled code here
end case;

<<my_loop2>>
for r_emp in (select last_name
from employees
where department_id = co_dept_purchasing
or commission_pct is not null
and 5=6)
-- "or commission_pct is not null" is dead code
for r_emp in (
select last_name
from employees
where department_id = co_dept_purchasing
or commission_pct is not null
and 5 = 6
)
-- "or commission_pct is not null" is dead code
loop
sys.dbms_output.put_line(r_emp.last_name);
end loop my_loop2;

return;
null; -- some dead code here
end;
Expand All @@ -62,10 +64,12 @@ begin
null; -- some further enabled code here

<<my_loop2>>
for r_emp in (select last_name
from employees
where department_id = co_dept_admin
or commission_pct is not null)
for r_emp in (
select last_name
from employees
where department_id = co_dept_admin
or commission_pct is not null
)
loop
sys.dbms_output.put_line(r_emp.last_name);
end loop my_loop2;
Expand Down
10 changes: 5 additions & 5 deletions 10 docs/4-language-usage/1-general/g-1050.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ begin
into l_job
from employees e
where e.manager_id is null;

if l_job = 'AD_PRES' then
null;
end if;
exception
when no_data_found then
when no_data_found then
null; -- handle_no_data_found;
when too_many_rows then
when too_many_rows then
null; -- handle_too_many_rows;
end;
/
Expand All @@ -54,9 +54,9 @@ begin
null;
end if;
exception
when no_data_found then
when no_data_found then
null; -- handle_no_data_found;
when too_many_rows then
when too_many_rows then
null; -- handle_too_many_rows;
end;
/
Expand Down
18 changes: 10 additions & 8 deletions 18 docs/4-language-usage/1-general/g-1060.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ Instead of using `rowid` for later reference to the original row one should use

``` sql
begin
insert into employees_log (employee_id
,last_name
,first_name
,rid)
select employee_id
insert into employees_log (
employee_id
,last_name
,first_name
,rid
)
select employee_id
,last_name
,first_name
,rowid
Expand All @@ -31,9 +33,9 @@ end;
``` sql
begin
insert into employees_log (employee_id
,last_name
,first_name)
select employee_id
,last_name
,first_name)
select employee_id
,last_name
,first_name
from employees;
Expand Down
11 changes: 6 additions & 5 deletions 11 docs/4-language-usage/1-general/g-1080.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,22 @@ This rule ignores operators `+`, `*` and `||`, and expressions: `1=1`, `1<>1`, `
``` sql
select emp.first_name
,emp.last_name
,emp.salary
,emp.salary
,emp.hire_date
from employees emp
where emp.salary > 3000 or emp.salary > 3000
order by emp.last_name, emp.first_name;
where emp.salary > 3000
or emp.salary > 3000
order by emp.last_name,emp.first_name;
```

## Example (good)

``` sql
select emp.first_name
,emp.last_name
,emp.salary
,emp.salary
,emp.hire_date
from employees emp
where emp.salary > 3000
order by emp.last_name, emp.first_name;
order by emp.last_name,emp.first_name;
```
12 changes: 8 additions & 4 deletions 12 docs/4-language-usage/2-variables-and-types/1-general/g-2110.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ create or replace package body my_package is
from employees e
where rownum = co_first_row;
exception
when no_data_found then null; -- handle no_data_found
when too_many_rows then null; -- handle too_many_rows (impossible)
when no_data_found then
null; -- handle no_data_found
when too_many_rows then
null; -- handle too_many_rows (impossible)
end my_proc;
end my_package;
/
Expand All @@ -40,8 +42,10 @@ create or replace package body my_package is
from employees e
where rownum = co_first_row;
exception
when no_data_found then null; -- handle no_data_found
when too_many_rows then null; -- handle too_many_rows (impossible)
when no_data_found then
null; -- handle no_data_found
when too_many_rows then
null; -- handle too_many_rows (impossible)
end my_proc;
end my_package;
/
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.