diff --git a/pmd-plsql/src/main/resources/rulesets/plsql/TomKytesDespair.xml b/pmd-plsql/src/main/resources/rulesets/plsql/TomKytesDespair.xml
index 44f45a03a5..b7147f6af4 100644
--- a/pmd-plsql/src/main/resources/rulesets/plsql/TomKytesDespair.xml
+++ b/pmd-plsql/src/main/resources/rulesets/plsql/TomKytesDespair.xml
@@ -3,73 +3,74 @@
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 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
-
- Rules based on Thomas Kyte's recommendations on http://asktom.oracle.com/ and http://tkyte.blogspot.com/.
-
-
- "WHEN OTHERS THEN NULL" hides all errors - (Re)RAISE an exception or call RAISE_APPLICATION_ERROR
+Rules based on Thomas Kyte's recommendations on http://asktom.oracle.com/ and http://tkyte.blogspot.com/.
- 3
-
-
-
+
+
+
+"WHEN OTHERS THEN NULL" hides all errors - (Re)RAISE an exception or call RAISE_APPLICATION_ERROR
+
+ 3
+
+
+
-
-
-
-
+
+
+
+
-
-
-
+
+
+
diff --git a/pmd-plsql/src/main/resources/rulesets/plsql/codesize.xml b/pmd-plsql/src/main/resources/rulesets/plsql/codesize.xml
index 7079e59dde..a0b80cbc43 100644
--- a/pmd-plsql/src/main/resources/rulesets/plsql/codesize.xml
+++ b/pmd-plsql/src/main/resources/rulesets/plsql/codesize.xml
@@ -8,394 +8,387 @@
The Code Size ruleset contains rules that find problems related to code size or complexity.
-
-
+
+
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.
-
- 3
+
+ 3
- 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;
+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;
-
- ]]>
+]]>
-
+
-
-
+
+
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.
-
- 3
-
+
+ 3
+
-
+
+
-
-
-
-
-
+
+
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.
-
- 3
-
+
+ 3
+
-
+
+
-
-
-
-
+
+
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 managable and ripe for reuse.
-
- 3
-
+
+ 3
+
-
-
+
+
-
-
+
+
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 managable and ripe for reuse.
-
- 3
-
+
+ 3
+
-
-
+
+
-
-
+
+
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 managable and ripe for reuse.
-
- 3
-
+
+ 3
+
-
-
+
+
-
-
+
+
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 managable and ripe for reuse.
-
- 3
-
+
+ 3
+
CREATE OR REPLACE
PACKAGE Foo AS
- PROCEDURE bar1 ;
- PROCEDURE bar2 ;
- PROCEDURE bar3 ;
-
- ..
-
- PROCEDURE barN ;
-END;
-
-
+ PROCEDURE bar1;
+ PROCEDURE bar2;
+ PROCEDURE bar3;
-
-
-
+
+
+
+
+
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.
- ]]>
-
- 3
-
+
+ 3
+
-
-
+
+
-
-
+
+
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.
-
- 3
-
-
+ 3
+
+
+
+
- ]]>
-
-
-
-
-
+
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.
3
-
+
-
-
+
+
-
+
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.
3
-
+
-
+
+
-
-
-
+
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.
- ]]>
-
- 3
-
-
-
-
-
+ 3
+
+
+
+
+ $maxmethods
]
- ]]>
-
-
-
-
+]]>
+
+
+
+
diff --git a/pmd-plsql/src/main/resources/rulesets/plsql/dates.xml b/pmd-plsql/src/main/resources/rulesets/plsql/dates.xml
index 41eefbf2d2..70339133d2 100644
--- a/pmd-plsql/src/main/resources/rulesets/plsql/dates.xml
+++ b/pmd-plsql/src/main/resources/rulesets/plsql/dates.xml
@@ -8,149 +8,150 @@
The Dates ruleset deals with PLSQL DATETIME usages.
-
-
- TO_DATE without date format- use TO_DATE(expression, date-format)
-
- 3
-
-
-
+
+
+TO_DATE without date format- use TO_DATE(expression, date-format)
+
+ 3
+
+
+
-
-
-
-
+
+
+
+
-
-
+
+
-
-
- TO_DATE(TO_CHAR(date-variable)) used to remove time component - use TRUNC(date-veriable)
-
- 3
-
-
-
+
+
+TO_DATE(TO_CHAR(date-variable)) used to remove time component - use TRUNC(date-veriable)
+
+ 3
+
+
+
-
-
-
-
+
+
+
+
-
-
+
+
-
-
- TO_TIMESTAMP without date format- use TO_TIMESTAMP(expression, date-format)
-
- 3
-
-
-
+
+
+TO_TIMESTAMP without date format- use TO_TIMESTAMP(expression, date-format)
+
+ 3
+
+
+
-
-
-
-
+
+
+
+
-
-
-
+
+
+
diff --git a/pmd-plsql/src/main/resources/rulesets/plsql/rulesets.properties b/pmd-plsql/src/main/resources/rulesets/plsql/rulesets.properties
index ae519eb457..018e4b3912 100644
--- a/pmd-plsql/src/main/resources/rulesets/plsql/rulesets.properties
+++ b/pmd-plsql/src/main/resources/rulesets/plsql/rulesets.properties
@@ -2,4 +2,8 @@
# BSD-style license; for more info see http://pmd.sourceforge.net/license.html
#
-rulesets.filenames=rulesets/plsql/codesize.xml,rulesets/plsql/dates.xml,rulesets/plsql/TomKytesDespair.xml,rulesets/plsql/strictsyntax.xml
+rulesets.filenames=\
+ rulesets/plsql/codesize.xml,\
+ rulesets/plsql/dates.xml,\
+ rulesets/plsql/TomKytesDespair.xml,\
+ rulesets/plsql/strictsyntax.xml
diff --git a/pmd-plsql/src/main/resources/rulesets/plsql/strictsyntax.xml b/pmd-plsql/src/main/resources/rulesets/plsql/strictsyntax.xml
index 5d88e3c523..c8f8d32265 100644
--- a/pmd-plsql/src/main/resources/rulesets/plsql/strictsyntax.xml
+++ b/pmd-plsql/src/main/resources/rulesets/plsql/strictsyntax.xml
@@ -8,12 +8,12 @@
The Strict Syntax ruleset contains rules that highlight invalid plsql syntax, which works, but should be avoided.
-
+
Oracle states that the PRAQMA AUTONOMOUS_TRANSACTION must be in the declaration block,
but the code does not complain, when being compiled on the 11g DB.
@@ -22,12 +22,15 @@ https://docs.oracle.com/cd/B28359_01/appdev.111/b28370/static.htm#BABIIHBJ
3
-
+
+]]>
+
-
+
-
+]]>
+
+