Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7d3bd09

Browse files
committed
Updates to stylecheck script to make it more robust and precise.
1 parent 160c3a8 commit 7d3bd09

1 file changed

Lines changed: 29 additions & 23 deletions

File tree

build/utplsql_style_check.sql

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
ALTER SESSION SET PLSCOPE_SETTINGS= 'IDENTIFIERS:ALL';
1+
alter session set plscope_settings= 'identifiers:all';
2+
set linesize 300
23

34
--install or comple all code here
45
exec dbms_utility.compile_schema(USER,compile_all => TRUE,reuse_settings => FALSE);
@@ -12,39 +13,44 @@ column errcnt_c noprint new_value errcnt_c
1213

1314
--find parameters that donot begin with A_
1415
prompt parameters should start with A_
15-
select NAME,TYPE,OBJECT_NAME,OBJECT_TYPE,USAGE,LINE,COL , count(*) over() errcnt_a
16-
from user_identifiers
17-
where type like 'FORMAL%' and usage = 'DECLARATION'
18-
and name != 'SELF'
19-
and name not like 'A#_%' escape '#'
20-
order by object_name, object_type, line, col
16+
select name, type, object_name, object_type, usage, line, col, count(*) over() errcnt_a
17+
from user_identifiers
18+
where type like 'FORMAL%' and usage = 'DECLARATION'
19+
and name != 'SELF'
20+
and name not like 'A#_%' escape '#'
21+
order by object_name, object_type, line, col
2122
;
2223

2324
prompt variables should start with L_
2425
--variables start with l_ or g_
25-
select NAME,TYPE,OBJECT_NAME,OBJECT_TYPE,USAGE,LINE,COL , count(*) over() errcnt_l
26-
from user_identifiers
27-
where type like 'VARIABLE' and usage = 'DECLARATION'
28-
and object_type not in ('TYPE')
29-
and (name not like 'L#_%' escape '#'
30-
and name not like 'G#_%' escape '#' --TODO: only valid on package level
31-
)
32-
order by object_name, object_type, line, col
26+
select i.name, i.type, i.object_name, i.object_type, i.usage, i.line, i.col, count(*) over() errcnt_l
27+
from user_identifiers i
28+
join user_identifiers p
29+
on p.object_name = i.object_name and p.object_type = i.object_type
30+
and i.usage_context_id = p.usage_id
31+
where i.type like 'VARIABLE' and i.usage = 'DECLARATION'
32+
and i.object_type not in ('TYPE')
33+
and (i.name not like 'L#_%' escape '#' and p.type in ('PROCEDURE','FUNCTION','ITERATOR')
34+
or i.name not like 'G#_%' escape '#' and p.type not in ('PROCEDURE','FUNCTION','ITERATOR'))
35+
and p.type != 'RECORD'
36+
order by object_name, object_type, line, col;
3337
;
3438

3539
--constants start with c_ or gc_
3640
prompt constants should start with C_
37-
select NAME,TYPE,OBJECT_NAME,OBJECT_TYPE,USAGE,LINE,COL , count(*) over() errcnt_c
38-
from user_identifiers
39-
where type like 'CONSTANT' and usage = 'DECLARATION'
40-
and (name not like 'C#_%' escape '#'
41-
and name not like 'GC#_%' escape '#'
42-
)
43-
order by object_name, object_type, line, col
41+
select i.name, i.type, i.object_name, i.object_type, i.usage, i.line, i.col, count(*) over() errcnt_c
42+
from user_identifiers i
43+
join user_identifiers p
44+
on p.object_name = i.object_name and p.object_type = i.object_type
45+
and i.usage_context_id = p.usage_id
46+
where i.type like 'CONSTANT' and i.usage = 'DECLARATION'
47+
and (i.name not like 'C#_%' escape '#' and p.type in ('PROCEDURE','FUNCTION','ITERATOR')
48+
or i.name not like 'GC#_%' escape '#' and p.type not in ('PROCEDURE','FUNCTION','ITERATOR'))
49+
order by object_name, object_type, line, col
4450
;
4551

4652

4753
exec :errcnt := nvl('&errcnt_a',0) + nvl('&errcnt_l',0) + nvl('&errcnt_c',0);
4854

4955
--quit :errcnt
50-
exit success
56+
exit success

0 commit comments

Comments
 (0)