Repository navigation
Expand file tree
/
Copy pathdesign.xml
More file actions
604 lines (566 loc) · 21.3 KB
/
Copy pathdesign.xml
File metadata and controls
604 lines (566 loc) · 21.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="Design"
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
<description>
Rules that help you discover design issues.
</description>
<rule name="CyclomaticComplexity"
language="plsql"
since="5.1"
message = "The {0} ''{1}'' has a Cyclomatic Complexity of {2}."
class="net.sourceforge.pmd.lang.plsql.rule.design.CyclomaticComplexityRule"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_plsql_design.html#cyclomaticcomplexity">
<description>
Complexity directly affects maintenance costs is determined by the number of decision points in a method
plus one for the method entry. The decision points include 'if', 'while', 'for', and 'case labels' calls.
Generally, numbers ranging from 1-4 denote low complexity, 5-7 denote moderate complexity, 8-10 denote
high complexity, and 11+ is very high complexity.
</description>
<priority>3</priority>
<example>
<![CDATA[
-- Cyclomatic Complexity of 25
CREATE OR REPLACE PACKAGE BODY pkg_pmd_working_sequence AS
1 PROCEDURE ty_logger IS BEGIN
2 IF true
THEN
DBMS_OUTPUT.PUT_LINE('IF/THEN l_Integer='||l_integer);
3 IF true
THEN
DBMS_OUTPUT.PUT_LINE('IF/THEN l_Integer='||l_integer);
4 IF true
THEN
DBMS_OUTPUT.PUT_LINE('IF/THEN l_Integer='||l_integer);
5 ELSIF false
THEN
DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
ELSE
DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
END IF;
6 ELSIF false
THEN
DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
7 IF true
THEN
DBMS_OUTPUT.PUT_LINE('IF/THEN l_Integer='||l_integer);
8 ELSIF false
THEN
DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
ELSE
DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
END IF;
ELSE
DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
9 IF true
THEN
DBMS_OUTPUT.PUT_LINE('IF/THEN l_Integer='||l_integer);
10 ELSIF false
THEN
DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
ELSE
DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
END IF;
END IF;
11 ELSIF false
THEN
DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
12 IF true
THEN
DBMS_OUTPUT.PUT_LINE('IF/THEN l_Integer='||l_integer);
13 IF true
THEN
DBMS_OUTPUT.PUT_LINE('IF/THEN l_Integer='||l_integer);
14 ELSIF false
THEN
DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
ELSE
DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
END IF;
15 ELSIF false
THEN
16 IF true
THEN
DBMS_OUTPUT.PUT_LINE('IF/THEN l_Integer='||l_integer);
17 ELSIF false
THEN
DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
ELSE
DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
END IF;
DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
ELSE
DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
END IF;
ELSE
DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
18 IF true
THEN
DBMS_OUTPUT.PUT_LINE('IF/THEN l_Integer='||l_integer);
19 IF true
THEN
DBMS_OUTPUT.PUT_LINE('IF/THEN l_Integer='||l_integer);
20 ELSIF false
THEN
DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
ELSE
DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
END IF;
21 ELSIF false
THEN
DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
22 IF true
THEN
DBMS_OUTPUT.PUT_LINE('IF/THEN l_Integer='||l_integer);
23 ELSIF false
THEN
DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
ELSE
DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
END IF;
ELSE
DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
24 IF true
THEN
DBMS_OUTPUT.PUT_LINE('IF/THEN l_Integer='||l_integer);
25 ELSIF false
THEN
DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
ELSE
DBMS_OUTPUT.PUT_LINE('ELSIF l_Integer='||l_integer);
END IF;
END IF;
END IF;
END;
END;
]]>
</example>
</rule>
<rule name="ExcessiveMethodLength"
language="plsql"
deprecated="true"
since="5.1"
message="Avoid really long methods ({0} lines found, threshold is {1})."
class="net.sourceforge.pmd.lang.plsql.rule.design.ExcessiveMethodLengthRule"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_plsql_design.html#excessivemethodlength">
<description>
When methods are excessively long this usually indicates that the method is doing more than its
name/signature might suggest. They also become challenging for others to digest since excessive
scrolling causes readers to lose focus.
Try to reduce the method length by creating helper methods and removing any copy/pasted code.
**Deprecated:** This rule is deprecated since PMD 7.19.0 and will be removed with PMD 8.0.0. Use {%rule NcssCount %} to find big methods.
</description>
<priority>3</priority>
<example>
<![CDATA[
CREATE OR REPLACE
PROCEDURE doSomething BEGIN
DBMS_OUTPUT.PUT_LINE("Hello world!");
DBMS_OUTPUT.PUT_LINE("Hello world!");
-- 98 copies omitted for brevity.
END;
]]>
</example>
</rule>
<rule name="ExcessiveObjectLength"
language="plsql"
deprecated="true"
since="5.1"
message="Avoid really long Oracle object specifications and bodies ({0} lines found, threshold is {1})."
class="net.sourceforge.pmd.lang.plsql.rule.design.ExcessiveObjectLengthRule"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_plsql_design.html#excessiveobjectlength">
<description>
Excessive object line lengths are usually indications that the object may be burdened with excessive
responsibilities that could be provided by other objects. In breaking these methods
apart the code becomes more manageable and ripe for reuse.
**Deprecated:** This rule is deprecated since PMD 7.19.0 and will be removed with PMD 8.0.0. Use {%rule NcssCount %} to find big objects.
</description>
<priority>3</priority>
<example>
<![CDATA[
CREATE OR REPLACE
PACKAGE BODY Foo AS
PROCEDURE bar1 IS BEGIN
-- 1000 lines of code
END bar1;
PROCEDURE bar2 IS BEGIN
-- 1000 lines of code
END bar2;
PROCEDURE bar3 IS BEGIN
-- 1000 lines of code
END bar3;
PROCEDURE barN IS BEGIN
-- 1000 lines of code
END barn;
END;
]]>
</example>
</rule>
<rule name="ExcessivePackageBodyLength"
language="plsql"
deprecated="true"
since="5.1"
message="Avoid really long Object Type and Package bodies ({0} lines found, threshold is {1})."
class="net.sourceforge.pmd.lang.plsql.rule.design.ExcessivePackageBodyLengthRule"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_plsql_design.html#excessivepackagebodylength">
<description>
Excessive class file lengths are usually indications that the class may be burdened with excessive
responsibilities that could be provided by external classes or functions. In breaking these methods
apart the code becomes more manageable and ripe for reuse.
**Deprecated:** This rule is deprecated since PMD 7.19.0 and will be removed with PMD 8.0.0. Use {%rule NcssCount %} to find big objects.
</description>
<priority>3</priority>
<example>
<![CDATA[
CREATE OR REPLACE
PACKAGE BODY Foo AS
PROCEDURE bar1 IS BEGIN
-- 1000 lines of code
END bar1;
PROCEDURE bar2 IS BEGIN
-- 1000 lines of code
END bar2;
PROCEDURE bar3 IS BEGIN
-- 1000 lines of code
END bar3;
PROCEDURE barN IS BEGIN
-- 1000 lines of code
END barn;
END;
]]>
</example>
</rule>
<rule name="ExcessivePackageSpecificationLength"
language="plsql"
deprecated="true"
since="5.1"
message="Avoid really long Package Specifications ({0} lines found, threshold is {1})."
class="net.sourceforge.pmd.lang.plsql.rule.design.ExcessivePackageSpecificationLengthRule"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_plsql_design.html#excessivepackagespecificationlength">
<description>
Excessive class file lengths are usually indications that the class may be burdened with excessive
responsibilities that could be provided by external classes or functions. In breaking these methods
apart the code becomes more manageable and ripe for reuse.
**Deprecated:** This rule is deprecated since PMD 7.19.0 and will be removed with PMD 8.0.0. Use {%rule NcssCount %} to find big objects.
</description>
<priority>3</priority>
<example>
<![CDATA[
CREATE OR REPLACE
PACKAGE Foo AS
PROCEDURE bar1;
PROCEDURE bar2;
PROCEDURE bar3;
...
PROCEDURE barN;
END;
]]>
</example>
</rule>
<rule name="ExcessiveParameterList"
language="plsql"
since="5.1"
message="Avoid long parameter lists ({0} parameters found, threshold is {1})."
class="net.sourceforge.pmd.lang.plsql.rule.design.ExcessiveParameterListRule"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_plsql_design.html#excessiveparameterlist">
<description>
Methods with numerous parameters are a challenge to maintain, especially if most of them share the
same datatype. These situations usually denote the need for new objects to wrap the numerous parameters.
</description>
<priority>3</priority>
<example>
<![CDATA[
CREATE OR REPLACE
PROCEDURE addPerson( -- too many arguments liable to be mixed up
birthYear pls_integer, birthMonth pls_integer, birthDate pls_integer, height pls_integer, weight pls_integer, ssn pls_integer) {
. . . .
END ADDPERSON;
CREATE OR REPLACE
PROCEDURE addPerson( -- preferred approach
birthdate DATE, measurements BodyMeasurements , ssn INTEGER) BEGIN
. . . .
END;
]]>
</example>
</rule>
<!--
<rule name="ExcessivePublicCount"
language="plsql"
since="5.1"
message="This class has a bunch of public methods and attributes"
class="net.sourceforge.pmd.lang.plsql.rule.design.ExcessivePublicCountRule"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_plsql_codesize.html#excessivepubliccount">
<description>
Classes with large numbers of public methods and attributes require disproportionate testing efforts
since combinational side effects grow rapidly and increase risk. Refactoring these classes into
smaller ones not only increases testability and reliability but also allows new variations to be
developed easily.
</description>
<priority>3</priority>
<example>
<![CDATA[
public class Foo {
public String value;
public Bar something;
public Variable var;
// [... more more public attributes ...]
public void doWork() {}
public void doMoreWork() {}
public void doWorkAgain() {}
// [... more more public methods ...]
}
]]>
</example>
</rule>
-->
<rule name="ExcessiveTypeLength"
language="plsql"
deprecated="true"
since="5.1"
message="Avoid really long Object Type specifications ({0} lines found, threshold is {1})."
class="net.sourceforge.pmd.lang.plsql.rule.design.ExcessiveTypeLengthRule"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_plsql_design.html#excessivetypelength">
<description>
Excessive class file lengths are usually indications that the class may be burdened with excessive
responsibilities that could be provided by external classes or functions. In breaking these methods
apart the code becomes more manageable and ripe for reuse.
**Deprecated:** This rule is deprecated since PMD 7.19.0 and will be removed with PMD 8.0.0. Use {%rule NcssCount %} to find big objects.
</description>
<priority>3</priority>
<example>
<![CDATA[
CREATE OR REPLACE
TYPE BODY Foo AS
MEMBER PROCEDURE bar1 IS BEGIN
-- 1000 lines of code
END bar1;
MEMBER PROCEDURE bar2 IS BEGIN
-- 1000 lines of code
END bar2;
MEMBER PROCEDURE bar3 IS BEGIN
-- 1000 lines of code
END bar3;
MEMBER PROCEDURE barN IS BEGIN
-- 1000 lines of code
END barn;
END;
]]>
</example>
</rule>
<rule name="NcssCount"
language="plsql"
message="The {0} ''{1}'' has a NCSS line count of {2} (limit: {3})."
since="7.19.0"
class="net.sourceforge.pmd.lang.plsql.rule.design.NcssCountRule"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_plsql_design.html#ncsscount">
<description>
This rule uses the NCSS (Non-Commenting Source Statements) metric to determine the number of lines
of code in a plsql type or method. NCSS ignores comments, blank lines, and only counts actual
statements. For more details on the calculation, see the documentation
{% jdoc plsql::lang.plsql.metrics.PlsqlMetrics#NCSS %}.
</description>
<priority>3</priority>
<example><![CDATA[
DECLARE -- total Ncss: 14
PROCEDURE bigMethod IS -- +1
x NUMBER; -- +1
y NUMBER := 2; -- +1
a BOOLEAN := FALSE; -- +1
b BOOLEAN := TRUE; -- +1
BEGIN
IF (a OR b) THEN -- +1
LOOP -- +1
x := x + 2; -- +1
EXIT WHEN x >= 12; -- +1
END LOOP;
DBMS_OUTPUT.PUT_LINE('done'); -- +1
ELSE -- +1
DBMS_OUTPUT.PUT_LINE('false'); -- +1
END IF;
EXCEPTION
WHEN PROGRAM_ERROR THEN DBMS_OUTPUT.PUT_LINE('Error Occurred'); -- +1
END bigMethod;
BEGIN
bigMethod(); -- +1
END;
]]>
</example>
</rule>
<rule name="NcssMethodCount"
message="The method {0}() has an NCSS line count of {1} (threshold is {2})"
language="plsql"
deprecated="true"
since="5.1"
class="net.sourceforge.pmd.lang.plsql.rule.design.NcssMethodCountRule"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_plsql_design.html#ncssmethodcount">
<description>
This rule uses the NCSS (Non-Commenting Source Statements) algorithm to determine the number of lines
of code for a given method. NCSS ignores comments, and counts actual statements. Using this algorithm,
lines of code that are split are counted as one.
**Deprecated:** This rule is deprecated since PMD 7.19.0 and will be removed with PMD 8.0.0. Use {% rule NcssCount %} instead.
</description>
<priority>3</priority>
<example>
<![CDATA[
CREATE OR REPLACE PACKAGE BODY AS
FUNCTION method RETURN INTEGER IS
BEGIN
RETURN 1;
END;
END;
]]>
</example>
</rule>
<rule name="NcssObjectCount"
message="The Oracle object {0} has a NCSS line count of {1} (threshold is {2})"
language="plsql"
deprecated="true"
since="5.1"
class="net.sourceforge.pmd.lang.plsql.rule.design.NcssObjectCountRule"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_plsql_design.html#ncssobjectcount">
<description>
This rule uses the NCSS (Non-Commenting Source Statements) algorithm to determine the number of lines
of code for a given Oracle object. NCSS ignores comments, and counts actual statements. Using this algorithm,
lines of code that are split are counted as one.
**Deprecated:** This rule is deprecated since PMD 7.19.0 and will be removed with PMD 8.0.0. Use {% rule NcssCount %} instead.
</description>
<priority>3</priority>
<example>
<![CDATA[
CREATE OR REPLACE PACKAGE pkg_ IS
PROCEDURE Foo IS
BEGIN
--this class only has 6 NCSS lines
super();
super();
END Foo;
END;
]]>
</example>
</rule>
<rule name="NPathComplexity"
language="plsql"
since="5.1"
message="The method {0}() has an NPath complexity of {1} (threshold is {2})"
class="net.sourceforge.pmd.lang.plsql.rule.design.NPathComplexityRule"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_plsql_design.html#npathcomplexity">
<description>
The NPath complexity of a method is the number of acyclic execution paths through that method.
A threshold of 200 is generally considered the point where measures should be taken to reduce
complexity and increase readability.
</description>
<priority>3</priority>
<example>
<![CDATA[
CREATE OR REPLACE
PROCEDURE bar AS BEGIN -- this is something more complex than it needs to be,
if (y) THEN -- it should be broken down into smaller methods or functions
for j IN 0 .. j-1 LOOP
if (j > r) THEN
doSomething;
while (f < 5 ) LOOP
anotherThing;
f := f - 27;
END LOOP;
else
tryThis();
END IF;
END LOOP;
END IF;
if ( r - n > 45) THEN
while (doMagic) LOOP
findRabbits;
END LOOP;
END IF;
BEGIN
doSomethingDangerous();
EXCEPTION WHEN FooException THEN
makeAmends;
BEGIN
dontDoItAgain;
EXCEPTION
WHEN OTHERS THEN
log_problem;
END;
END;
END;
]]>
</example>
</rule>
<rule name="TooManyFields"
language="plsql"
since="5.1"
message="Too many fields"
class="net.sourceforge.pmd.lang.plsql.rule.design.TooManyFieldsRule"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_plsql_design.html#toomanyfields">
<description>
Classes that have too many fields can become unwieldy and could be redesigned to have fewer fields,
possibly through grouping related fields in new objects. For example, a class with individual
city/state/zip fields could park them within a single Address field.
</description>
<priority>3</priority>
<example>
<![CDATA[
CREATE OR REPLACE PACKAGE pkg_too_many_fields AS
C_CHAR_A CONSTANT CHAR(1 CHAR) := 'A';
C_CHAR_B CONSTANT CHAR(1 CHAR) := 'B';
...
C_CHAR_Z CONSTANT CHAR(1 CHAR) := 'Z';
END pkg_too_many_fields;
]]>
</example>
</rule>
<rule name="TooManyMethods"
language="plsql"
since="5.1"
class="net.sourceforge.pmd.lang.rule.xpath.XPathRule"
message="This object has too many methods, consider refactoring it."
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_plsql_design.html#toomanymethods">
<description>
A package or type with too many methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to
have more fine grained objects.
</description>
<priority>3</priority>
<properties>
<property name="maxmethods" type="Integer" description="The method count reporting threshold" min="1" max="1000" value="1"/>
<property name="xpath">
<value>
<![CDATA[
//node()
[ (
local-name(.) = 'PackageSpecification'
or
local-name(.) = 'TypeSpecification'
)
and
(
count(/descendant::ProgramUnit[
not (
starts-with(@Name,'get')
or
starts-with(@Name,'set')
or
starts-with(@Name,'is')
)
]
)
+
count(/descendant::TypeMethod[
not (
starts-with(@Name,'get')
or
starts-with(@Name,'set')
or
starts-with(@Name,'is')
)
]
)
) > $maxmethods
]
]]>
</value>
</property>
</properties>
</rule>
</ruleset>