forked from phoedos/pmd
Merge branch 'pr-705'
This commit is contained in:
@ -5,33 +5,33 @@ folder: pmd/rules
|
||||
---
|
||||
List of rulesets and rules contained in each ruleset.
|
||||
|
||||
* [Code Size](pmd_rules_plsql_codesize.html): The Code Size ruleset contains rules that find problems related to code size or complexity.
|
||||
* [PLSQL DATETIME](pmd_rules_plsql_dates.html): The Dates ruleset deals with PLSQL DATETIME usages.
|
||||
* [Strict Syntax](pmd_rules_plsql_strictsyntax.html): The Strict Syntax ruleset contains rules that highlight invalid plsql syntax, which works, but should be avoided.
|
||||
* [Tom Kyte's Despair](pmd_rules_plsql_TomKytesDespair.html): Rules based on Thomas Kyte's recommendations on http://asktom.oracle.com/ and http://tkyte.blogspot.com/.
|
||||
* [Best Practices](pmd_rules_plsql_bestpractices.html): Rules which enforce generally accepted best practices.
|
||||
* [Codestyle](pmd_rules_plsql_codestyle.html): Rules which enforce a specific coding style.
|
||||
* [Design](pmd_rules_plsql_design.html): Rules that help you discover design issues.
|
||||
* [Error Prone](pmd_rules_plsql_errorprone.html): Rules to detect constructs that are either broken, extremely confusing or prone to runtime errors.
|
||||
|
||||
## Code Size
|
||||
* [CyclomaticComplexity](pmd_rules_plsql_codesize.html#cyclomaticcomplexity): Complexity directly affects maintenance costs is determined by the number of decision points in a...
|
||||
* [ExcessiveMethodLength](pmd_rules_plsql_codesize.html#excessivemethodlength): When methods are excessively long this usually indicates that the method is doing more than itsna...
|
||||
* [ExcessiveObjectLength](pmd_rules_plsql_codesize.html#excessiveobjectlength): Excessive object line lengths are usually indications that the object may be burdened with excess...
|
||||
* [ExcessivePackageBodyLength](pmd_rules_plsql_codesize.html#excessivepackagebodylength): Excessive class file lengths are usually indications that the class may be burdened with excessiv...
|
||||
* [ExcessivePackageSpecificationLength](pmd_rules_plsql_codesize.html#excessivepackagespecificationlength): Excessive class file lengths are usually indications that the class may be burdened with excessiv...
|
||||
* [ExcessiveParameterList](pmd_rules_plsql_codesize.html#excessiveparameterlist): Methods with numerous parameters are a challenge to maintain, especially if most of them share th...
|
||||
* [ExcessiveTypeLength](pmd_rules_plsql_codesize.html#excessivetypelength): Excessive class file lengths are usually indications that the class may be burdened with excessiv...
|
||||
* [NcssMethodCount](pmd_rules_plsql_codesize.html#ncssmethodcount): This rule uses the NCSS (Non-Commenting Source Statements) algorithm to determine the number of l...
|
||||
* [NcssObjectCount](pmd_rules_plsql_codesize.html#ncssobjectcount): This rule uses the NCSS (Non-Commenting Source Statements) algorithm to determine the number of l...
|
||||
* [NPathComplexity](pmd_rules_plsql_codesize.html#npathcomplexity): The NPath complexity of a method is the number of acyclic execution paths through that method.A t...
|
||||
* [TooManyFields](pmd_rules_plsql_codesize.html#toomanyfields): Classes that have too many fields can become unwieldy and could be redesigned to have fewer field...
|
||||
* [TooManyMethods](pmd_rules_plsql_codesize.html#toomanymethods): A package or type with too many methods is probably a good suspect for refactoring, in order to r...
|
||||
## Best Practices
|
||||
* [TomKytesDespair](pmd_rules_plsql_bestpractices.html#tomkytesdespair): "WHEN OTHERS THEN NULL" hides all errors - (Re)RAISE an exception or call RAISE_APPLICATION_ERROR
|
||||
|
||||
## PLSQL DATETIME
|
||||
* [TO_DATE_TO_CHAR](pmd_rules_plsql_dates.html#to_date_to_char): TO_DATE(TO_CHAR(date-variable)) used to remove time component - use TRUNC(date-veriable)
|
||||
* [TO_DATEWithoutDateFormat](pmd_rules_plsql_dates.html#to_datewithoutdateformat): TO_DATE without date format- use TO_DATE(expression, date-format)
|
||||
* [TO_TIMESTAMPWithoutDateFormat](pmd_rules_plsql_dates.html#to_timestampwithoutdateformat): TO_TIMESTAMP without date format- use TO_TIMESTAMP(expression, date-format)
|
||||
## Codestyle
|
||||
* [MisplacedPragma](pmd_rules_plsql_codestyle.html#misplacedpragma): Oracle states that the PRAQMA AUTONOMOUS_TRANSACTION must be in the declaration block,but the cod...
|
||||
|
||||
## Strict Syntax
|
||||
* [MisplacedPragma](pmd_rules_plsql_strictsyntax.html#misplacedpragma): Oracle states that the PRAQMA AUTONOMOUS_TRANSACTION must be in the declaration block,but the cod...
|
||||
## Design
|
||||
* [CyclomaticComplexity](pmd_rules_plsql_design.html#cyclomaticcomplexity): Complexity directly affects maintenance costs is determined by the number of decision points in a...
|
||||
* [ExcessiveMethodLength](pmd_rules_plsql_design.html#excessivemethodlength): When methods are excessively long this usually indicates that the method is doing more than itsna...
|
||||
* [ExcessiveObjectLength](pmd_rules_plsql_design.html#excessiveobjectlength): Excessive object line lengths are usually indications that the object may be burdened with excess...
|
||||
* [ExcessivePackageBodyLength](pmd_rules_plsql_design.html#excessivepackagebodylength): Excessive class file lengths are usually indications that the class may be burdened with excessiv...
|
||||
* [ExcessivePackageSpecificationLength](pmd_rules_plsql_design.html#excessivepackagespecificationlength): Excessive class file lengths are usually indications that the class may be burdened with excessiv...
|
||||
* [ExcessiveParameterList](pmd_rules_plsql_design.html#excessiveparameterlist): Methods with numerous parameters are a challenge to maintain, especially if most of them share th...
|
||||
* [ExcessiveTypeLength](pmd_rules_plsql_design.html#excessivetypelength): Excessive class file lengths are usually indications that the class may be burdened with excessiv...
|
||||
* [NcssMethodCount](pmd_rules_plsql_design.html#ncssmethodcount): This rule uses the NCSS (Non-Commenting Source Statements) algorithm to determine the number of l...
|
||||
* [NcssObjectCount](pmd_rules_plsql_design.html#ncssobjectcount): This rule uses the NCSS (Non-Commenting Source Statements) algorithm to determine the number of l...
|
||||
* [NPathComplexity](pmd_rules_plsql_design.html#npathcomplexity): The NPath complexity of a method is the number of acyclic execution paths through that method.A t...
|
||||
* [TooManyFields](pmd_rules_plsql_design.html#toomanyfields): Classes that have too many fields can become unwieldy and could be redesigned to have fewer field...
|
||||
* [TooManyMethods](pmd_rules_plsql_design.html#toomanymethods): A package or type with too many methods is probably a good suspect for refactoring, in order to r...
|
||||
|
||||
## Tom Kyte's Despair
|
||||
* [TomKytesDespair](pmd_rules_plsql_TomKytesDespair.html#tomkytesdespair): "WHEN OTHERS THEN NULL" hides all errors - (Re)RAISE an exception or call RAISE_APPLICATION_ERROR
|
||||
## Error Prone
|
||||
* [TO_DATE_TO_CHAR](pmd_rules_plsql_errorprone.html#to_date_to_char): TO_DATE(TO_CHAR(date-variable)) used to remove time component - use TRUNC(date-variable)
|
||||
* [TO_DATEWithoutDateFormat](pmd_rules_plsql_errorprone.html#to_datewithoutdateformat): TO_DATE without date format- use TO_DATE(expression, date-format)
|
||||
* [TO_TIMESTAMPWithoutDateFormat](pmd_rules_plsql_errorprone.html#to_timestampwithoutdateformat): TO_TIMESTAMP without date format- use TO_TIMESTAMP(expression, date-format)
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
---
|
||||
title: Tom Kyte's Despair
|
||||
summary: Rules based on Thomas Kyte's recommendations on http://asktom.oracle.com/ and http://tkyte.blogspot.com/.
|
||||
permalink: pmd_rules_plsql_TomKytesDespair.html
|
||||
title: Best Practices
|
||||
summary: Rules which enforce generally accepted best practices.
|
||||
permalink: pmd_rules_plsql_bestpractices.html
|
||||
folder: pmd/rules/plsql
|
||||
sidebaractiveurl: /pmd_rules_plsql.html
|
||||
editmepath: ../pmd-plsql/src/main/resources/rulesets/plsql/TomKytesDespair.xml
|
||||
keywords: Tom Kyte's Despair, TomKytesDespair
|
||||
editmepath: ../pmd-plsql/src/main/resources/category/plsql/bestpractices.xml
|
||||
keywords: Best Practices, TomKytesDespair
|
||||
---
|
||||
## TomKytesDespair
|
||||
|
||||
@ -66,6 +66,6 @@ END update_planned_hrs;
|
||||
|
||||
**Use this rule by referencing it:**
|
||||
``` xml
|
||||
<rule ref="rulesets/plsql/TomKytesDespair.xml/TomKytesDespair" />
|
||||
<rule ref="rulesets/plsql/bestpractices.xml/TomKytesDespair" />
|
||||
```
|
||||
|
@ -1,11 +1,11 @@
|
||||
---
|
||||
title: Strict Syntax
|
||||
summary: The Strict Syntax ruleset contains rules that highlight invalid plsql syntax, which works, but should be avoided.
|
||||
permalink: pmd_rules_plsql_strictsyntax.html
|
||||
title: Codestyle
|
||||
summary: Rules which enforce a specific coding style.
|
||||
permalink: pmd_rules_plsql_codestyle.html
|
||||
folder: pmd/rules/plsql
|
||||
sidebaractiveurl: /pmd_rules_plsql.html
|
||||
editmepath: ../pmd-plsql/src/main/resources/rulesets/plsql/strictsyntax.xml
|
||||
keywords: Strict Syntax, MisplacedPragma
|
||||
editmepath: ../pmd-plsql/src/main/resources/category/plsql/codestyle.xml
|
||||
keywords: Codestyle, MisplacedPragma
|
||||
---
|
||||
## MisplacedPragma
|
||||
|
||||
@ -44,6 +44,6 @@ end inline_pragma_error;
|
||||
|
||||
**Use this rule by referencing it:**
|
||||
``` xml
|
||||
<rule ref="rulesets/plsql/strictsyntax.xml/MisplacedPragma" />
|
||||
<rule ref="rulesets/plsql/codestyle.xml/MisplacedPragma" />
|
||||
```
|
||||
|
@ -1,11 +1,11 @@
|
||||
---
|
||||
title: Code Size
|
||||
summary: The Code Size ruleset contains rules that find problems related to code size or complexity.
|
||||
permalink: pmd_rules_plsql_codesize.html
|
||||
title: Design
|
||||
summary: Rules that help you discover design issues.
|
||||
permalink: pmd_rules_plsql_design.html
|
||||
folder: pmd/rules/plsql
|
||||
sidebaractiveurl: /pmd_rules_plsql.html
|
||||
editmepath: ../pmd-plsql/src/main/resources/rulesets/plsql/codesize.xml
|
||||
keywords: Code Size, NPathComplexity, ExcessiveMethodLength, ExcessiveParameterList, ExcessiveObjectLength, ExcessiveTypeLength, ExcessivePackageBodyLength, ExcessivePackageSpecificationLength, CyclomaticComplexity, TooManyFields, NcssMethodCount, NcssObjectCount, TooManyMethods
|
||||
editmepath: ../pmd-plsql/src/main/resources/category/plsql/design.xml
|
||||
keywords: Design, CyclomaticComplexity, ExcessiveMethodLength, ExcessiveObjectLength, ExcessivePackageBodyLength, ExcessivePackageSpecificationLength, ExcessiveParameterList, ExcessiveTypeLength, NcssMethodCount, NcssObjectCount, NPathComplexity, TooManyFields, TooManyMethods
|
||||
---
|
||||
## CyclomaticComplexity
|
||||
|
||||
@ -18,7 +18,7 @@ plus one for the method entry. The decision points include 'if', 'while', 'for'
|
||||
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.
|
||||
|
||||
**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.plsql.rule.codesize.CyclomaticComplexityRule](https://github.com/pmd/pmd/blob/master/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/codesize/CyclomaticComplexityRule.java)
|
||||
**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.plsql.rule.design.CyclomaticComplexityRule](https://github.com/pmd/pmd/blob/master/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/design/CyclomaticComplexityRule.java)
|
||||
|
||||
**Example(s):**
|
||||
|
||||
@ -149,7 +149,7 @@ END;
|
||||
|
||||
**Use this rule by referencing it:**
|
||||
``` xml
|
||||
<rule ref="rulesets/plsql/codesize.xml/CyclomaticComplexity" />
|
||||
<rule ref="rulesets/plsql/design.xml/CyclomaticComplexity" />
|
||||
```
|
||||
|
||||
## ExcessiveMethodLength
|
||||
@ -163,7 +163,7 @@ name/signature might suggest. They also become challenging for others to digest
|
||||
scrolling causes readers to lose focus.
|
||||
Try to reduce the method length by creating helper methods and removing any copy/pasted code.
|
||||
|
||||
**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.plsql.rule.codesize.ExcessiveMethodLengthRule](https://github.com/pmd/pmd/blob/master/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/codesize/ExcessiveMethodLengthRule.java)
|
||||
**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.plsql.rule.design.ExcessiveMethodLengthRule](https://github.com/pmd/pmd/blob/master/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/design/ExcessiveMethodLengthRule.java)
|
||||
|
||||
**Example(s):**
|
||||
|
||||
@ -186,7 +186,7 @@ END;
|
||||
|
||||
**Use this rule by referencing it:**
|
||||
``` xml
|
||||
<rule ref="rulesets/plsql/codesize.xml/ExcessiveMethodLength" />
|
||||
<rule ref="rulesets/plsql/design.xml/ExcessiveMethodLength" />
|
||||
```
|
||||
|
||||
## ExcessiveObjectLength
|
||||
@ -199,7 +199,7 @@ Excessive object line lengths are usually indications that the object may be bur
|
||||
responsibilities that could be provided by other objects. In breaking these methods
|
||||
apart the code becomes more managable and ripe for reuse.
|
||||
|
||||
**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.plsql.rule.codesize.ExcessiveObjectLengthRule](https://github.com/pmd/pmd/blob/master/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/codesize/ExcessiveObjectLengthRule.java)
|
||||
**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.plsql.rule.design.ExcessiveObjectLengthRule](https://github.com/pmd/pmd/blob/master/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/design/ExcessiveObjectLengthRule.java)
|
||||
|
||||
**Example(s):**
|
||||
|
||||
@ -233,7 +233,7 @@ END;
|
||||
|
||||
**Use this rule by referencing it:**
|
||||
``` xml
|
||||
<rule ref="rulesets/plsql/codesize.xml/ExcessiveObjectLength" />
|
||||
<rule ref="rulesets/plsql/design.xml/ExcessiveObjectLength" />
|
||||
```
|
||||
|
||||
## ExcessivePackageBodyLength
|
||||
@ -246,7 +246,7 @@ Excessive class file lengths are usually indications that the class may be burde
|
||||
responsibilities that could be provided by external classes or functions. In breaking these methods
|
||||
apart the code becomes more managable and ripe for reuse.
|
||||
|
||||
**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.plsql.rule.codesize.ExcessivePackageBodyLengthRule](https://github.com/pmd/pmd/blob/master/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/codesize/ExcessivePackageBodyLengthRule.java)
|
||||
**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.plsql.rule.design.ExcessivePackageBodyLengthRule](https://github.com/pmd/pmd/blob/master/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/design/ExcessivePackageBodyLengthRule.java)
|
||||
|
||||
**Example(s):**
|
||||
|
||||
@ -280,7 +280,7 @@ END;
|
||||
|
||||
**Use this rule by referencing it:**
|
||||
``` xml
|
||||
<rule ref="rulesets/plsql/codesize.xml/ExcessivePackageBodyLength" />
|
||||
<rule ref="rulesets/plsql/design.xml/ExcessivePackageBodyLength" />
|
||||
```
|
||||
|
||||
## ExcessivePackageSpecificationLength
|
||||
@ -293,7 +293,7 @@ Excessive class file lengths are usually indications that the class may be burde
|
||||
responsibilities that could be provided by external classes or functions. In breaking these methods
|
||||
apart the code becomes more managable and ripe for reuse.
|
||||
|
||||
**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.plsql.rule.codesize.ExcessivePackageSpecificationLengthRule](https://github.com/pmd/pmd/blob/master/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/codesize/ExcessivePackageSpecificationLengthRule.java)
|
||||
**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.plsql.rule.design.ExcessivePackageSpecificationLengthRule](https://github.com/pmd/pmd/blob/master/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/design/ExcessivePackageSpecificationLengthRule.java)
|
||||
|
||||
**Example(s):**
|
||||
|
||||
@ -320,7 +320,7 @@ END;
|
||||
|
||||
**Use this rule by referencing it:**
|
||||
``` xml
|
||||
<rule ref="rulesets/plsql/codesize.xml/ExcessivePackageSpecificationLength" />
|
||||
<rule ref="rulesets/plsql/design.xml/ExcessivePackageSpecificationLength" />
|
||||
```
|
||||
|
||||
## ExcessiveParameterList
|
||||
@ -332,7 +332,7 @@ END;
|
||||
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.
|
||||
|
||||
**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.plsql.rule.codesize.ExcessiveParameterListRule](https://github.com/pmd/pmd/blob/master/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/codesize/ExcessiveParameterListRule.java)
|
||||
**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.plsql.rule.design.ExcessiveParameterListRule](https://github.com/pmd/pmd/blob/master/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/design/ExcessiveParameterListRule.java)
|
||||
|
||||
**Example(s):**
|
||||
|
||||
@ -362,7 +362,7 @@ END;
|
||||
|
||||
**Use this rule by referencing it:**
|
||||
``` xml
|
||||
<rule ref="rulesets/plsql/codesize.xml/ExcessiveParameterList" />
|
||||
<rule ref="rulesets/plsql/design.xml/ExcessiveParameterList" />
|
||||
```
|
||||
|
||||
## ExcessiveTypeLength
|
||||
@ -375,7 +375,7 @@ Excessive class file lengths are usually indications that the class may be burde
|
||||
responsibilities that could be provided by external classes or functions. In breaking these methods
|
||||
apart the code becomes more managable and ripe for reuse.
|
||||
|
||||
**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.plsql.rule.codesize.ExcessiveTypeLengthRule](https://github.com/pmd/pmd/blob/master/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/codesize/ExcessiveTypeLengthRule.java)
|
||||
**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.plsql.rule.design.ExcessiveTypeLengthRule](https://github.com/pmd/pmd/blob/master/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/design/ExcessiveTypeLengthRule.java)
|
||||
|
||||
**Example(s):**
|
||||
|
||||
@ -409,7 +409,7 @@ END;
|
||||
|
||||
**Use this rule by referencing it:**
|
||||
``` xml
|
||||
<rule ref="rulesets/plsql/codesize.xml/ExcessiveTypeLength" />
|
||||
<rule ref="rulesets/plsql/design.xml/ExcessiveTypeLength" />
|
||||
```
|
||||
|
||||
## NcssMethodCount
|
||||
@ -422,7 +422,7 @@ This rule uses the NCSS (Non-Commenting Source Statements) algorithm to determin
|
||||
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.
|
||||
|
||||
**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.plsql.rule.codesize.NcssMethodCountRule](https://github.com/pmd/pmd/blob/master/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/codesize/NcssMethodCountRule.java)
|
||||
**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.plsql.rule.design.NcssMethodCountRule](https://github.com/pmd/pmd/blob/master/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/design/NcssMethodCountRule.java)
|
||||
|
||||
**Example(s):**
|
||||
|
||||
@ -445,7 +445,7 @@ END;
|
||||
|
||||
**Use this rule by referencing it:**
|
||||
``` xml
|
||||
<rule ref="rulesets/plsql/codesize.xml/NcssMethodCount" />
|
||||
<rule ref="rulesets/plsql/design.xml/NcssMethodCount" />
|
||||
```
|
||||
|
||||
## NcssObjectCount
|
||||
@ -458,7 +458,7 @@ This rule uses the NCSS (Non-Commenting Source Statements) algorithm to determin
|
||||
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.
|
||||
|
||||
**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.plsql.rule.codesize.NcssObjectCountRule](https://github.com/pmd/pmd/blob/master/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/codesize/NcssObjectCountRule.java)
|
||||
**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.plsql.rule.design.NcssObjectCountRule](https://github.com/pmd/pmd/blob/master/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/design/NcssObjectCountRule.java)
|
||||
|
||||
**Example(s):**
|
||||
|
||||
@ -483,7 +483,7 @@ CREATE OR REPLACE PACKAGE pkg_
|
||||
|
||||
**Use this rule by referencing it:**
|
||||
``` xml
|
||||
<rule ref="rulesets/plsql/codesize.xml/NcssObjectCount" />
|
||||
<rule ref="rulesets/plsql/design.xml/NcssObjectCount" />
|
||||
```
|
||||
|
||||
## NPathComplexity
|
||||
@ -496,7 +496,7 @@ The NPath complexity of a method is the number of acyclic execution paths throug
|
||||
A threshold of 200 is generally considered the point where measures should be taken to reduce
|
||||
complexity and increase readability.
|
||||
|
||||
**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.plsql.rule.codesize.NPathComplexityRule](https://github.com/pmd/pmd/blob/master/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/codesize/NPathComplexityRule.java)
|
||||
**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.plsql.rule.design.NPathComplexityRule](https://github.com/pmd/pmd/blob/master/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/design/NPathComplexityRule.java)
|
||||
|
||||
**Example(s):**
|
||||
|
||||
@ -545,7 +545,7 @@ END;
|
||||
|
||||
**Use this rule by referencing it:**
|
||||
``` xml
|
||||
<rule ref="rulesets/plsql/codesize.xml/NPathComplexity" />
|
||||
<rule ref="rulesets/plsql/design.xml/NPathComplexity" />
|
||||
```
|
||||
|
||||
## TooManyFields
|
||||
@ -558,7 +558,7 @@ Classes that have too many fields can become unwieldy and could be redesigned to
|
||||
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.
|
||||
|
||||
**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.plsql.rule.codesize.TooManyFieldsRule](https://github.com/pmd/pmd/blob/master/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/codesize/TooManyFieldsRule.java)
|
||||
**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.plsql.rule.design.TooManyFieldsRule](https://github.com/pmd/pmd/blob/master/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/design/TooManyFieldsRule.java)
|
||||
|
||||
**Example(s):**
|
||||
|
||||
@ -579,7 +579,7 @@ END pkg_too_many_fields;
|
||||
|
||||
**Use this rule by referencing it:**
|
||||
``` xml
|
||||
<rule ref="rulesets/plsql/codesize.xml/TooManyFields" />
|
||||
<rule ref="rulesets/plsql/design.xml/TooManyFields" />
|
||||
```
|
||||
|
||||
## TooManyMethods
|
||||
@ -633,6 +633,6 @@ have more fine grained objects.
|
||||
|
||||
**Use this rule by referencing it:**
|
||||
``` xml
|
||||
<rule ref="rulesets/plsql/codesize.xml/TooManyMethods" />
|
||||
<rule ref="rulesets/plsql/design.xml/TooManyMethods" />
|
||||
```
|
||||
|
@ -1,11 +1,11 @@
|
||||
---
|
||||
title: PLSQL DATETIME
|
||||
summary: The Dates ruleset deals with PLSQL DATETIME usages.
|
||||
permalink: pmd_rules_plsql_dates.html
|
||||
title: Error Prone
|
||||
summary: Rules to detect constructs that are either broken, extremely confusing or prone to runtime errors.
|
||||
permalink: pmd_rules_plsql_errorprone.html
|
||||
folder: pmd/rules/plsql
|
||||
sidebaractiveurl: /pmd_rules_plsql.html
|
||||
editmepath: ../pmd-plsql/src/main/resources/rulesets/plsql/dates.xml
|
||||
keywords: PLSQL DATETIME, TO_DATEWithoutDateFormat, TO_DATE_TO_CHAR, TO_TIMESTAMPWithoutDateFormat
|
||||
editmepath: ../pmd-plsql/src/main/resources/category/plsql/errorprone.xml
|
||||
keywords: Error Prone, TO_DATE_TO_CHAR, TO_DATEWithoutDateFormat, TO_TIMESTAMPWithoutDateFormat
|
||||
---
|
||||
## TO_DATE_TO_CHAR
|
||||
|
||||
@ -13,7 +13,7 @@ keywords: PLSQL DATETIME, TO_DATEWithoutDateFormat, TO_DATE_TO_CHAR, TO_TIMESTAM
|
||||
|
||||
**Priority:** Medium (3)
|
||||
|
||||
TO_DATE(TO_CHAR(date-variable)) used to remove time component - use TRUNC(date-veriable)
|
||||
TO_DATE(TO_CHAR(date-variable)) used to remove time component - use TRUNC(date-variable)
|
||||
|
||||
```
|
||||
//PrimaryExpression
|
||||
@ -30,8 +30,8 @@ TO_DATE(TO_CHAR(date-variable)) used to remove time component - use TRUNC(date-v
|
||||
``` sql
|
||||
CREATE OR REPLACE PACKAGE BODY date_utilities
|
||||
IS
|
||||
|
||||
-- Take single parameter, relyimg on current default NLS date format
|
||||
|
||||
-- Take single parameter, relying on current default NLS date format
|
||||
FUNCTION strip_time (p_date IN DATE) RETURN DATE
|
||||
IS
|
||||
BEGIN
|
||||
@ -45,7 +45,7 @@ END date_utilities;
|
||||
|
||||
**Use this rule by referencing it:**
|
||||
``` xml
|
||||
<rule ref="rulesets/plsql/dates.xml/TO_DATE_TO_CHAR" />
|
||||
<rule ref="rulesets/plsql/errorprone.xml/TO_DATE_TO_CHAR" />
|
||||
```
|
||||
|
||||
## TO_DATEWithoutDateFormat
|
||||
@ -66,7 +66,7 @@ TO_DATE without date format- use TO_DATE(expression, date-format)
|
||||
CREATE OR REPLACE PACKAGE BODY date_utilities
|
||||
IS
|
||||
|
||||
-- Take single parameter, relyimg on current default NLS date format
|
||||
-- Take single parameter, relying on current default NLS date format
|
||||
FUNCTION to_date_single_parameter (p_date_string IN VARCHAR2) RETURN DATE
|
||||
IS
|
||||
BEGIN
|
||||
@ -93,7 +93,7 @@ END date_utilities;
|
||||
|
||||
**Use this rule by referencing it:**
|
||||
``` xml
|
||||
<rule ref="rulesets/plsql/dates.xml/TO_DATEWithoutDateFormat" />
|
||||
<rule ref="rulesets/plsql/errorprone.xml/TO_DATEWithoutDateFormat" />
|
||||
```
|
||||
|
||||
## TO_TIMESTAMPWithoutDateFormat
|
||||
@ -114,7 +114,7 @@ TO_TIMESTAMP without date format- use TO_TIMESTAMP(expression, date-format)
|
||||
CREATE OR REPLACE PACKAGE BODY date_utilities
|
||||
IS
|
||||
|
||||
-- Take single parameter, relyimg on current default NLS date format
|
||||
-- Take single parameter, relying on current default NLS date format
|
||||
FUNCTION to_timestamp_single_parameter (p_date_string IN VARCHAR2) RETURN DATE
|
||||
IS
|
||||
BEGIN
|
||||
@ -141,6 +141,6 @@ END date_utilities;
|
||||
|
||||
**Use this rule by referencing it:**
|
||||
``` xml
|
||||
<rule ref="rulesets/plsql/dates.xml/TO_TIMESTAMPWithoutDateFormat" />
|
||||
<rule ref="rulesets/plsql/errorprone.xml/TO_TIMESTAMPWithoutDateFormat" />
|
||||
```
|
||||
|
@ -2,7 +2,7 @@
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.plsql.rule.codesize;
|
||||
package net.sourceforge.pmd.lang.plsql.rule.design;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
@ -2,7 +2,7 @@
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.plsql.rule.codesize;
|
||||
package net.sourceforge.pmd.lang.plsql.rule.design;
|
||||
|
||||
import java.util.Stack;
|
||||
import java.util.logging.Level;
|
@ -2,10 +2,9 @@
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.plsql.rule.codesize;
|
||||
package net.sourceforge.pmd.lang.plsql.rule.design;
|
||||
|
||||
import net.sourceforge.pmd.lang.plsql.ast.ExecutableCode;
|
||||
import net.sourceforge.pmd.lang.plsql.rule.design.ExcessiveLengthRule;
|
||||
|
||||
/**
|
||||
* This rule detects when a method exceeds a certain threshold. i.e. if a method
|
@ -2,10 +2,9 @@
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.plsql.rule.codesize;
|
||||
package net.sourceforge.pmd.lang.plsql.rule.design;
|
||||
|
||||
import net.sourceforge.pmd.lang.plsql.ast.OracleObject;
|
||||
import net.sourceforge.pmd.lang.plsql.rule.design.ExcessiveLengthRule;
|
||||
|
||||
/**
|
||||
* This rule detects when an Oracle object exceeds a certain threshold. i.e. if
|
@ -2,10 +2,9 @@
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.plsql.rule.codesize;
|
||||
package net.sourceforge.pmd.lang.plsql.rule.design;
|
||||
|
||||
import net.sourceforge.pmd.lang.plsql.ast.ASTPackageBody;
|
||||
import net.sourceforge.pmd.lang.plsql.rule.design.ExcessiveLengthRule;
|
||||
|
||||
/**
|
||||
* This rule detects when a class exceeds a certain threshold. i.e. if a class
|
@ -2,10 +2,9 @@
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.plsql.rule.codesize;
|
||||
package net.sourceforge.pmd.lang.plsql.rule.design;
|
||||
|
||||
import net.sourceforge.pmd.lang.plsql.ast.ASTPackageSpecification;
|
||||
import net.sourceforge.pmd.lang.plsql.rule.design.ExcessiveLengthRule;
|
||||
|
||||
/**
|
||||
* This rule detects when a class exceeds a certain threshold. i.e. if a class
|
@ -2,11 +2,10 @@
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.plsql.rule.codesize;
|
||||
package net.sourceforge.pmd.lang.plsql.rule.design;
|
||||
|
||||
import net.sourceforge.pmd.lang.plsql.ast.ASTFormalParameter;
|
||||
import net.sourceforge.pmd.lang.plsql.ast.ASTFormalParameters;
|
||||
import net.sourceforge.pmd.lang.plsql.rule.design.ExcessiveNodeCountRule;
|
||||
import net.sourceforge.pmd.util.NumericConstants;
|
||||
|
||||
/**
|
@ -2,10 +2,9 @@
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.plsql.rule.codesize;
|
||||
package net.sourceforge.pmd.lang.plsql.rule.design;
|
||||
|
||||
import net.sourceforge.pmd.lang.plsql.ast.ASTTypeSpecification;
|
||||
import net.sourceforge.pmd.lang.plsql.rule.design.ExcessiveLengthRule;
|
||||
|
||||
/**
|
||||
* This rule detects when a class exceeds a certain threshold. i.e. if a class
|
@ -2,7 +2,7 @@
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.plsql.rule.codesize;
|
||||
package net.sourceforge.pmd.lang.plsql.rule.design;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
@ -2,7 +2,7 @@
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.plsql.rule.codesize;
|
||||
package net.sourceforge.pmd.lang.plsql.rule.design;
|
||||
|
||||
import net.sourceforge.pmd.lang.plsql.ast.ExecutableCode;
|
||||
import net.sourceforge.pmd.stat.DataPoint;
|
@ -2,7 +2,7 @@
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.plsql.rule.codesize;
|
||||
package net.sourceforge.pmd.lang.plsql.rule.design;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
@ -2,7 +2,7 @@
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.plsql.rule.codesize;
|
||||
package net.sourceforge.pmd.lang.plsql.rule.design;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
@ -0,0 +1,78 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<ruleset name="Best Practices"
|
||||
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">
|
||||
|
||||
<description>
|
||||
Rules which enforce generally accepted best practices.
|
||||
</description>
|
||||
|
||||
|
||||
<rule name="TomKytesDespair"
|
||||
language="plsql"
|
||||
since="5.1"
|
||||
message="WHEN OTHERS THEN NULL - when you do this, Tom Kyte cries"
|
||||
class="net.sourceforge.pmd.lang.rule.XPathRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_plsql_bestpractices.html#tomkytesdespair">
|
||||
<description>
|
||||
"WHEN OTHERS THEN NULL" hides all errors - (Re)RAISE an exception or call RAISE_APPLICATION_ERROR
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
<properties>
|
||||
<property name="xpath">
|
||||
<value>
|
||||
<![CDATA[
|
||||
//ExceptionHandler[QualifiedName/@Image='OTHERS' and upper-case(Statement/UnlabelledStatement/Expression/@Image)='NULL']
|
||||
]]>
|
||||
</value>
|
||||
</property>
|
||||
</properties>
|
||||
<example>
|
||||
<![CDATA[
|
||||
CREATE OR REPLACE PACKAGE BODY update_planned_hrs
|
||||
IS
|
||||
|
||||
PROCEDURE set_new_planned (p_emp_id IN NUMBER, p_project_id IN NUMBER, p_hours IN NUMBER)
|
||||
IS
|
||||
BEGIN
|
||||
UPDATE employee_on_activity ea
|
||||
SET ea.ea_planned_hours = p_hours
|
||||
WHERE
|
||||
ea.ea_emp_id = p_emp_id
|
||||
AND ea.ea_proj_id = p_project_id;
|
||||
|
||||
EXCEPTION
|
||||
WHEN NO_DATA_FOUND THEN
|
||||
RAISE_APPLICATION_ERROR (-20100, 'No such employee or project');
|
||||
|
||||
END set_new_planned;
|
||||
|
||||
FUNCTION existing_planned (p_emp_id IN NUMBER, p_project_id IN NUMBER) RETURN NUMBER
|
||||
|
||||
IS
|
||||
|
||||
existing_hours NUMBER(4);
|
||||
|
||||
BEGIN
|
||||
SELECT ea.ea_planned_hours INTO existing_hours
|
||||
FROM employee_on_activity ea
|
||||
WHERE
|
||||
ea.ea_emp_id = p_emp_id
|
||||
AND ea.ea_proj_id = p_project_id;
|
||||
|
||||
RETURN (existing_hours);
|
||||
|
||||
EXCEPTION
|
||||
WHEN OTHERS THEN NULL;
|
||||
|
||||
END existing_planned;
|
||||
|
||||
END update_planned_hrs;
|
||||
/
|
||||
]]>
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
</ruleset>
|
55
pmd-plsql/src/main/resources/category/plsql/codestyle.xml
Normal file
55
pmd-plsql/src/main/resources/category/plsql/codestyle.xml
Normal file
@ -0,0 +1,55 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<ruleset name="Codestyle"
|
||||
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">
|
||||
|
||||
<description>
|
||||
Rules which enforce a specific coding style.
|
||||
</description>
|
||||
|
||||
<rule name="MisplacedPragma"
|
||||
language="plsql"
|
||||
since="5.5.2"
|
||||
message="Pragma should be used only inside the declaration block before 'BEGIN'."
|
||||
class="net.sourceforge.pmd.lang.rule.XPathRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_plsql_codestyle.html#misplacedpragma">
|
||||
<description>
|
||||
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.
|
||||
https://docs.oracle.com/cd/B28359_01/appdev.111/b28370/static.htm#BABIIHBJ
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
<properties>
|
||||
<property name="xpath">
|
||||
<value>
|
||||
<![CDATA[
|
||||
//ProgramUnit/Pragma
|
||||
]]>
|
||||
</value>
|
||||
</property>
|
||||
</properties>
|
||||
<example>
|
||||
<![CDATA[
|
||||
create or replace package inline_pragma_error is
|
||||
|
||||
end;
|
||||
/
|
||||
|
||||
create or replace package body inline_pragma_error is
|
||||
procedure do_transaction(p_input_token in varchar(200)) is
|
||||
PRAGMA AUTONOMOUS_TRANSACTION; /* this is correct place for PRAGMA */
|
||||
begin
|
||||
PRAGMA AUTONOMOUS_TRANSACTION; /* this is the wrong place for PRAGMA -> violation */
|
||||
/* do something */
|
||||
COMMIT;
|
||||
end do_transaction;
|
||||
|
||||
end inline_pragma_error;
|
||||
/
|
||||
]]>
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
</ruleset>
|
542
pmd-plsql/src/main/resources/category/plsql/design.xml
Normal file
542
pmd-plsql/src/main/resources/category/plsql/design.xml
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<ruleset name="Documentation"
|
||||
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">
|
||||
|
||||
<description>
|
||||
Rules that are related to code documentation.
|
||||
</description>
|
||||
</ruleset>
|
158
pmd-plsql/src/main/resources/category/plsql/errorprone.xml
Normal file
158
pmd-plsql/src/main/resources/category/plsql/errorprone.xml
Normal file
@ -0,0 +1,158 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<ruleset name="Error Prone"
|
||||
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">
|
||||
|
||||
<description>
|
||||
Rules to detect constructs that are either broken, extremely confusing or prone to runtime errors.
|
||||
</description>
|
||||
|
||||
<rule name="TO_DATE_TO_CHAR"
|
||||
language="plsql"
|
||||
since="5.1"
|
||||
message="TO_DATE(TO_CHAR(variable)) instead of TRUNC(variable)"
|
||||
class="net.sourceforge.pmd.lang.rule.XPathRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_plsql_errorprone.html#to_date_to_char">
|
||||
<description>
|
||||
TO_DATE(TO_CHAR(date-variable)) used to remove time component - use TRUNC(date-variable)
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
<properties>
|
||||
<property name="xpath">
|
||||
<value>
|
||||
<![CDATA[
|
||||
//PrimaryExpression
|
||||
[PrimaryPrefix/Name/@Image='TO_DATE']
|
||||
[count(PrimarySuffix/Arguments/ArgumentList/Argument) = 1]
|
||||
[.//PrimaryExpression
|
||||
[PrimaryPrefix/Name/@Image='TO_CHAR']
|
||||
[count(PrimarySuffix/Arguments/ArgumentList/Argument) = 1]
|
||||
]
|
||||
]]>
|
||||
</value>
|
||||
</property>
|
||||
</properties>
|
||||
<example>
|
||||
<![CDATA[
|
||||
CREATE OR REPLACE PACKAGE BODY date_utilities
|
||||
IS
|
||||
|
||||
-- Take single parameter, relying on current default NLS date format
|
||||
FUNCTION strip_time (p_date IN DATE) RETURN DATE
|
||||
IS
|
||||
BEGIN
|
||||
RETURN TO_DATE(TO_CHAR(p_date));
|
||||
END strip_time;
|
||||
|
||||
|
||||
END date_utilities;
|
||||
/
|
||||
]]>
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
<rule name="TO_DATEWithoutDateFormat"
|
||||
language="plsql"
|
||||
since="5.1"
|
||||
message="TO_DATE without date format"
|
||||
class="net.sourceforge.pmd.lang.rule.XPathRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_plsql_errorprone.html#to_datewithoutdateformat">
|
||||
<description>
|
||||
TO_DATE without date format- use TO_DATE(expression, date-format)
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
<properties>
|
||||
<property name="xpath">
|
||||
<value>
|
||||
<![CDATA[
|
||||
//PrimaryExpression[PrimaryPrefix/Name/@Image='TO_DATE' and count(PrimarySuffix/Arguments/ArgumentList/Argument) = 1 ]
|
||||
]]>
|
||||
</value>
|
||||
</property>
|
||||
</properties>
|
||||
<example>
|
||||
<![CDATA[
|
||||
CREATE OR REPLACE PACKAGE BODY date_utilities
|
||||
IS
|
||||
|
||||
-- Take single parameter, relying on current default NLS date format
|
||||
FUNCTION to_date_single_parameter (p_date_string IN VARCHAR2) RETURN DATE
|
||||
IS
|
||||
BEGIN
|
||||
RETURN TO_DATE(p_date_string);
|
||||
END to_date_single_parameter ;
|
||||
|
||||
-- Take 2 parameters, using an explicit date format string
|
||||
FUNCTION to_date_two_parameters (p_date_string IN VARCHAR2, p_format_mask IN VARCHAR2) RETURN DATE
|
||||
IS
|
||||
BEGIN
|
||||
TO_DATE(p_date_string, p_date_format);
|
||||
END to_date_two_parameters;
|
||||
|
||||
-- Take 3 parameters, using an explicit date format string and an explicit language
|
||||
FUNCTION to_date_three_parameters (p_date_string IN VARCHAR2, p_format_mask IN VARCHAR2, p_nls_language VARCHAR2 ) RETURN DATE
|
||||
IS
|
||||
BEGIN
|
||||
TO_DATE(p_date_string, p_format_mask, p_nls_language);
|
||||
END to_date_three_parameters;
|
||||
|
||||
END date_utilities;
|
||||
/
|
||||
]]>
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
<rule name="TO_TIMESTAMPWithoutDateFormat"
|
||||
language="plsql"
|
||||
message="TO_TIMESTAMP without date format"
|
||||
class="net.sourceforge.pmd.lang.rule.XPathRule"
|
||||
since="5.1"
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_plsql_errorprone.html#to_timestampwithoutdateformat">
|
||||
<description>
|
||||
TO_TIMESTAMP without date format- use TO_TIMESTAMP(expression, date-format)
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
<properties>
|
||||
<property name="xpath">
|
||||
<value>
|
||||
<![CDATA[
|
||||
//PrimaryExpression[PrimaryPrefix/Name/@Image='TO_TIMESTAMP' and count(PrimarySuffix/Arguments/ArgumentList/Argument) = 1 ]
|
||||
]]>
|
||||
</value>
|
||||
</property>
|
||||
</properties>
|
||||
<example>
|
||||
<![CDATA[
|
||||
CREATE OR REPLACE PACKAGE BODY date_utilities
|
||||
IS
|
||||
|
||||
-- Take single parameter, relying on current default NLS date format
|
||||
FUNCTION to_timestamp_single_parameter (p_date_string IN VARCHAR2) RETURN DATE
|
||||
IS
|
||||
BEGIN
|
||||
RETURN TO_TIMESTAMP(p_date_string);
|
||||
END to_timestamp_single_parameter;
|
||||
|
||||
-- Take 2 parameters, using an explicit date format string
|
||||
FUNCTION to_timestamp_two_parameters (p_date_string IN VARCHAR2, p_format_mask IN VARCHAR2) RETURN DATE
|
||||
IS
|
||||
BEGIN
|
||||
TO_TIMESTAMP(p_date_string, p_date_format);
|
||||
END to_timestamp_two_parameters;
|
||||
|
||||
-- Take 3 parameters, using an explicit date format string and an explicit language
|
||||
FUNCTION to_timestamp_three_parameters (p_date_string IN VARCHAR2, p_format_mask IN VARCHAR2, p_nls_language VARCHAR2 ) RETURN DATE
|
||||
IS
|
||||
BEGIN
|
||||
TO_TIMESTAMP(p_date_string, p_format_mask, p_nls_language);
|
||||
END to_timestamp_three_parameters;
|
||||
|
||||
END date_utilities;
|
||||
/
|
||||
]]>
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
</ruleset>
|
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<ruleset name="Multithreading"
|
||||
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">
|
||||
|
||||
<description>
|
||||
Rules that flag issues when dealing with multiple threads of execution.
|
||||
</description>
|
||||
</ruleset>
|
11
pmd-plsql/src/main/resources/category/plsql/performance.xml
Normal file
11
pmd-plsql/src/main/resources/category/plsql/performance.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<ruleset name="Performance"
|
||||
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">
|
||||
|
||||
<description>
|
||||
Rules that flag suboptimal code.
|
||||
</description>
|
||||
</ruleset>
|
11
pmd-plsql/src/main/resources/category/plsql/security.xml
Normal file
11
pmd-plsql/src/main/resources/category/plsql/security.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<ruleset name="Security"
|
||||
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">
|
||||
|
||||
<description>
|
||||
Rules that flag potential security flaws.
|
||||
</description>
|
||||
</ruleset>
|
@ -8,69 +8,6 @@
|
||||
Rules based on Thomas Kyte's recommendations on http://asktom.oracle.com/ and http://tkyte.blogspot.com/.
|
||||
</description>
|
||||
|
||||
<rule name="TomKytesDespair"
|
||||
language="plsql"
|
||||
since="5.1"
|
||||
message="WHEN OTHERS THEN NULL - when you do this, Tom Kyte cries"
|
||||
class="net.sourceforge.pmd.lang.rule.XPathRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_plsql_TomKytesDespair.html#tomkytesdespair">
|
||||
<description>
|
||||
"WHEN OTHERS THEN NULL" hides all errors - (Re)RAISE an exception or call RAISE_APPLICATION_ERROR
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
<properties>
|
||||
<property name="xpath">
|
||||
<value>
|
||||
<![CDATA[
|
||||
//ExceptionHandler[QualifiedName/@Image='OTHERS' and upper-case(Statement/UnlabelledStatement/Expression/@Image)='NULL']
|
||||
]]>
|
||||
</value>
|
||||
</property>
|
||||
</properties>
|
||||
<example>
|
||||
<![CDATA[
|
||||
CREATE OR REPLACE PACKAGE BODY update_planned_hrs
|
||||
IS
|
||||
|
||||
PROCEDURE set_new_planned (p_emp_id IN NUMBER, p_project_id IN NUMBER, p_hours IN NUMBER)
|
||||
IS
|
||||
BEGIN
|
||||
UPDATE employee_on_activity ea
|
||||
SET ea.ea_planned_hours = p_hours
|
||||
WHERE
|
||||
ea.ea_emp_id = p_emp_id
|
||||
AND ea.ea_proj_id = p_project_id;
|
||||
|
||||
EXCEPTION
|
||||
WHEN NO_DATA_FOUND THEN
|
||||
RAISE_APPLICATION_ERROR (-20100, 'No such employee or project');
|
||||
|
||||
END set_new_planned;
|
||||
|
||||
FUNCTION existing_planned (p_emp_id IN NUMBER, p_project_id IN NUMBER) RETURN NUMBER
|
||||
|
||||
IS
|
||||
|
||||
existing_hours NUMBER(4);
|
||||
|
||||
BEGIN
|
||||
SELECT ea.ea_planned_hours INTO existing_hours
|
||||
FROM employee_on_activity ea
|
||||
WHERE
|
||||
ea.ea_emp_id = p_emp_id
|
||||
AND ea.ea_proj_id = p_project_id;
|
||||
|
||||
RETURN (existing_hours);
|
||||
|
||||
EXCEPTION
|
||||
WHEN OTHERS THEN NULL;
|
||||
|
||||
END existing_planned;
|
||||
|
||||
END update_planned_hrs;
|
||||
/
|
||||
]]>
|
||||
</example>
|
||||
</rule>
|
||||
<rule ref="category/plsql/bestpractices.xml/TomKytesDespair" deprecated="true" />
|
||||
|
||||
</ruleset>
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -8,150 +8,8 @@
|
||||
The Dates ruleset deals with PLSQL DATETIME usages.
|
||||
</description>
|
||||
|
||||
<rule name="TO_DATEWithoutDateFormat"
|
||||
language="plsql"
|
||||
since="5.1"
|
||||
message="TO_DATE without date format"
|
||||
class="net.sourceforge.pmd.lang.rule.XPathRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_plsql_dates.html#to_datewithoutdateformat">
|
||||
<description>
|
||||
TO_DATE without date format- use TO_DATE(expression, date-format)
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
<properties>
|
||||
<property name="xpath">
|
||||
<value>
|
||||
<![CDATA[
|
||||
//PrimaryExpression[PrimaryPrefix/Name/@Image='TO_DATE' and count(PrimarySuffix/Arguments/ArgumentList/Argument) = 1 ]
|
||||
]]>
|
||||
</value>
|
||||
</property>
|
||||
</properties>
|
||||
<example>
|
||||
<![CDATA[
|
||||
CREATE OR REPLACE PACKAGE BODY date_utilities
|
||||
IS
|
||||
|
||||
-- Take single parameter, relyimg on current default NLS date format
|
||||
FUNCTION to_date_single_parameter (p_date_string IN VARCHAR2) RETURN DATE
|
||||
IS
|
||||
BEGIN
|
||||
RETURN TO_DATE(p_date_string);
|
||||
END to_date_single_parameter ;
|
||||
|
||||
-- Take 2 parameters, using an explicit date format string
|
||||
FUNCTION to_date_two_parameters (p_date_string IN VARCHAR2, p_format_mask IN VARCHAR2) RETURN DATE
|
||||
IS
|
||||
BEGIN
|
||||
TO_DATE(p_date_string, p_date_format);
|
||||
END to_date_two_parameters;
|
||||
|
||||
-- Take 3 parameters, using an explicit date format string and an explicit language
|
||||
FUNCTION to_date_three_parameters (p_date_string IN VARCHAR2, p_format_mask IN VARCHAR2, p_nls_language VARCHAR2 ) RETURN DATE
|
||||
IS
|
||||
BEGIN
|
||||
TO_DATE(p_date_string, p_format_mask, p_nls_language);
|
||||
END to_date_three_parameters;
|
||||
|
||||
END date_utilities;
|
||||
/
|
||||
]]>
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
<rule name="TO_DATE_TO_CHAR"
|
||||
language="plsql"
|
||||
since="5.1"
|
||||
message="TO_DATE(TO_CHAR(variable)) instead of TRUNC(variable)"
|
||||
class="net.sourceforge.pmd.lang.rule.XPathRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_plsql_dates.html#to_date_to_char">
|
||||
<description>
|
||||
TO_DATE(TO_CHAR(date-variable)) used to remove time component - use TRUNC(date-veriable)
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
<properties>
|
||||
<property name="xpath">
|
||||
<value>
|
||||
<![CDATA[
|
||||
//PrimaryExpression
|
||||
[PrimaryPrefix/Name/@Image='TO_DATE']
|
||||
[count(PrimarySuffix/Arguments/ArgumentList/Argument) = 1]
|
||||
[.//PrimaryExpression
|
||||
[PrimaryPrefix/Name/@Image='TO_CHAR']
|
||||
[count(PrimarySuffix/Arguments/ArgumentList/Argument) = 1]
|
||||
]
|
||||
]]>
|
||||
</value>
|
||||
</property>
|
||||
</properties>
|
||||
<example>
|
||||
<![CDATA[
|
||||
CREATE OR REPLACE PACKAGE BODY date_utilities
|
||||
IS
|
||||
|
||||
-- Take single parameter, relyimg on current default NLS date format
|
||||
FUNCTION strip_time (p_date IN DATE) RETURN DATE
|
||||
IS
|
||||
BEGIN
|
||||
RETURN TO_DATE(TO_CHAR(p_date));
|
||||
END strip_time;
|
||||
|
||||
|
||||
END date_utilities;
|
||||
/
|
||||
]]>
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
<rule name="TO_TIMESTAMPWithoutDateFormat"
|
||||
language="plsql"
|
||||
message="TO_TIMESTAMP without date format"
|
||||
class="net.sourceforge.pmd.lang.rule.XPathRule"
|
||||
since="5.1"
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_plsql_dates.html#to_timestampwithoutdateformat">
|
||||
<description>
|
||||
TO_TIMESTAMP without date format- use TO_TIMESTAMP(expression, date-format)
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
<properties>
|
||||
<property name="xpath">
|
||||
<value>
|
||||
<![CDATA[
|
||||
//PrimaryExpression[PrimaryPrefix/Name/@Image='TO_TIMESTAMP' and count(PrimarySuffix/Arguments/ArgumentList/Argument) = 1 ]
|
||||
]]>
|
||||
</value>
|
||||
</property>
|
||||
</properties>
|
||||
<example>
|
||||
<![CDATA[
|
||||
CREATE OR REPLACE PACKAGE BODY date_utilities
|
||||
IS
|
||||
|
||||
-- Take single parameter, relyimg on current default NLS date format
|
||||
FUNCTION to_timestamp_single_parameter (p_date_string IN VARCHAR2) RETURN DATE
|
||||
IS
|
||||
BEGIN
|
||||
RETURN TO_TIMESTAMP(p_date_string);
|
||||
END to_timestamp_single_parameter;
|
||||
|
||||
-- Take 2 parameters, using an explicit date format string
|
||||
FUNCTION to_timestamp_two_parameters (p_date_string IN VARCHAR2, p_format_mask IN VARCHAR2) RETURN DATE
|
||||
IS
|
||||
BEGIN
|
||||
TO_TIMESTAMP(p_date_string, p_date_format);
|
||||
END to_timestamp_two_parameters;
|
||||
|
||||
-- Take 3 parameters, using an explicit date format string and an explicit language
|
||||
FUNCTION to_timestamp_three_parameters (p_date_string IN VARCHAR2, p_format_mask IN VARCHAR2, p_nls_language VARCHAR2 ) RETURN DATE
|
||||
IS
|
||||
BEGIN
|
||||
TO_TIMESTAMP(p_date_string, p_format_mask, p_nls_language);
|
||||
END to_timestamp_three_parameters;
|
||||
|
||||
END date_utilities;
|
||||
/
|
||||
]]>
|
||||
</example>
|
||||
</rule>
|
||||
<rule ref="category/plsql/errorprone.xml/TO_DATE_TO_CHAR" deprecated="true" />
|
||||
<rule ref="category/plsql/errorprone.xml/TO_DATEWithoutDateFormat" deprecated="true" />
|
||||
<rule ref="category/plsql/errorprone.xml/TO_TIMESTAMPWithoutDateFormat" deprecated="true" />
|
||||
|
||||
</ruleset>
|
||||
|
@ -3,7 +3,15 @@
|
||||
#
|
||||
|
||||
rulesets.filenames=\
|
||||
rulesets/plsql/codesize.xml,\
|
||||
rulesets/plsql/dates.xml,\
|
||||
rulesets/plsql/TomKytesDespair.xml,\
|
||||
rulesets/plsql/strictsyntax.xml
|
||||
category/plsql/bestpractices.xml,\
|
||||
category/plsql/codestyle.xml,\
|
||||
category/plsql/design.xml,\
|
||||
category/plsql/errorprone.xml
|
||||
|
||||
#
|
||||
# categories without rules
|
||||
#
|
||||
# category/plsql/documentation.xml
|
||||
# category/plsql/multithreading.xml
|
||||
# category/plsql/performance.xml
|
||||
# category/plsql/security.xml
|
||||
|
@ -8,47 +8,6 @@
|
||||
The Strict Syntax ruleset contains rules that highlight invalid plsql syntax, which works, but should be avoided.
|
||||
</description>
|
||||
|
||||
<rule name="MisplacedPragma"
|
||||
language="plsql"
|
||||
since="5.5.2"
|
||||
message="Pragma should be used only inside the declaration block before 'BEGIN'."
|
||||
class="net.sourceforge.pmd.lang.rule.XPathRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_plsql_strictsyntax.html#misplacedpragma">
|
||||
<description>
|
||||
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.
|
||||
https://docs.oracle.com/cd/B28359_01/appdev.111/b28370/static.htm#BABIIHBJ
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
<properties>
|
||||
<property name="xpath">
|
||||
<value>
|
||||
<![CDATA[
|
||||
//ProgramUnit/Pragma
|
||||
]]>
|
||||
</value>
|
||||
</property>
|
||||
</properties>
|
||||
<example>
|
||||
<![CDATA[
|
||||
create or replace package inline_pragma_error is
|
||||
|
||||
end;
|
||||
/
|
||||
|
||||
create or replace package body inline_pragma_error is
|
||||
procedure do_transaction(p_input_token in varchar(200)) is
|
||||
PRAGMA AUTONOMOUS_TRANSACTION; /* this is correct place for PRAGMA */
|
||||
begin
|
||||
PRAGMA AUTONOMOUS_TRANSACTION; /* this is the wrong place for PRAGMA -> violation */
|
||||
/* do something */
|
||||
COMMIT;
|
||||
end do_transaction;
|
||||
|
||||
end inline_pragma_error;
|
||||
/
|
||||
]]>
|
||||
</example>
|
||||
</rule>
|
||||
<rule ref="category/plsql/codestyle.xml/MisplacedPragma" deprecated="true" />
|
||||
|
||||
</ruleset>
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user