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

Skip to content

Commit dbb7a07

Browse files
committed
add simple naming check script. compile with warnings. ignore warnings in install error check
1 parent 45f212f commit dbb7a07

3 files changed

Lines changed: 70 additions & 2 deletions

File tree

.travis/install.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,9 @@ set -ev
55
cd source
66
#install core of utplsql
77
"$ORACLE_HOME/bin/sqlplus" $UT3_USER/$UT3_PASSWORD @install.sql
8+
9+
10+
cd ..
11+
cd build
12+
#do style check
13+
"$ORACLE_HOME/bin/sqlplus" $UT3_USER/$UT3_PASSWORD @utplsql_style_check.sql

build/utplsql_style_check.sql

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
--ALTER SESSION SET PLSCOPE_SETTINGS= 'IDENTIFIERS:ALL';
2+
3+
--install or comple all code here
4+
--exec dbms_utility.compile_schema(USER,compile_all => TRUE,reuse_settings => FALSE);
5+
6+
7+
var errcnt number
8+
9+
column errcnt_a noprint new_value errcnt_a
10+
column errcnt_l noprint new_value errcnt_l
11+
column errcnt_c noprint new_value errcnt_c
12+
13+
--find parameters that donot begin with A_
14+
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
21+
;
22+
23+
prompt variables should start with L_
24+
--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
33+
;
34+
35+
--constants start with c_ or gc_
36+
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
44+
;
45+
46+
47+
exec :errcnt := nvl('&errcnt_a',0) + nvl('&errcnt_l',0) + nvl('&errcnt_c',0);
48+
49+
quit :errcnt

source/install.sql

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
prompt Installing utplsql framework
22

3+
set serveroutput on size unlimited
4+
set timing off
5+
set define off
6+
7+
ALTER SESSION SET PLSQL_WARNINGS = 'ENABLE:ALL', 'DISABLE:(6000,6001,6003,6010, 7206)';
8+
9+
310
whenever sqlerror exit failure rollback
411
whenever oserror exit failure rollback
512

@@ -126,14 +133,20 @@ whenever oserror exit failure rollback
126133

127134

128135
prompt Validating installation
129-
select * from user_errors where name not like 'BIN$%' and (name like 'UT%' or name in ('EQUAL','BE_TRUE','BE_FALSE','BE_NULL','BE_NOT_NULL','MATCH','BE_LIKE'));
136+
select * from user_errors
137+
where name not like 'BIN$%' --not recycled
138+
and (name like 'UT%' or name in ('BE_FALSE','BE_LIKE','BE_NOT_NULL','BE_NULL','BE_TRUE','EQUAL','MATCH')) -- utplsql objects
139+
and attribute = 'ERROR'; -- erors only. ignore warnings
130140

131141
declare
132142
l_cnt integer;
133143
begin
134144
select count(1)
135145
into l_cnt
136-
from user_errors where name not like 'BIN$%' and (name like 'UT%' or name in ('EQUAL','BE_TRUE','BE_FALSE','BE_NULL','BE_NOT_NULL','MATCH','BE_LIKE'));
146+
from user_errors
147+
where name not like 'BIN$%'
148+
and (name like 'UT%' or name in ('BE_FALSE','BE_LIKE','BE_NOT_NULL','BE_NULL','BE_TRUE','EQUAL','MATCH'))
149+
and attribute = 'ERROR';
137150
if l_cnt > 0 then
138151
raise_application_error(-20000, 'Not all sources were successfully installed.');
139152
end if;

0 commit comments

Comments
 (0)