forked from phoedos/pmd
Update documentation
TRAVIS_JOB_NUMBER=2665.1 TRAVIS_COMMIT_RANGE=ecdd3ad2a793...3820bdc36c75
This commit is contained in:
@ -16,6 +16,7 @@ folder: pmd/rules
|
|||||||
|
|
||||||
{% include callout.html content="Rules which enforce a specific coding style." %}
|
{% include callout.html content="Rules which enforce a specific coding style." %}
|
||||||
|
|
||||||
|
* [ForLoopNaming](pmd_rules_plsql_codestyle.html#forloopnaming): In case you have loops please name the loop variables more meaningful.
|
||||||
* [MisplacedPragma](pmd_rules_plsql_codestyle.html#misplacedpragma): Oracle states that the PRAQMA AUTONOMOUS_TRANSACTION must be in the declaration block,but the cod...
|
* [MisplacedPragma](pmd_rules_plsql_codestyle.html#misplacedpragma): Oracle states that the PRAQMA AUTONOMOUS_TRANSACTION must be in the declaration block,but the cod...
|
||||||
|
|
||||||
## Design
|
## Design
|
||||||
|
@ -5,9 +5,73 @@ permalink: pmd_rules_plsql_codestyle.html
|
|||||||
folder: pmd/rules/plsql
|
folder: pmd/rules/plsql
|
||||||
sidebaractiveurl: /pmd_rules_plsql.html
|
sidebaractiveurl: /pmd_rules_plsql.html
|
||||||
editmepath: ../pmd-plsql/src/main/resources/category/plsql/codestyle.xml
|
editmepath: ../pmd-plsql/src/main/resources/category/plsql/codestyle.xml
|
||||||
keywords: Code Style, MisplacedPragma
|
keywords: Code Style, MisplacedPragma, ForLoopNaming
|
||||||
language: PLSQL
|
language: PLSQL
|
||||||
---
|
---
|
||||||
|
## ForLoopNaming
|
||||||
|
|
||||||
|
**Since:** PMD 6.7.0
|
||||||
|
|
||||||
|
**Priority:** Medium (3)
|
||||||
|
|
||||||
|
In case you have loops please name the loop variables more meaningful.
|
||||||
|
|
||||||
|
**This rule is defined by the following XPath expression:**
|
||||||
|
``` xpath
|
||||||
|
//CursorForLoopStatement[
|
||||||
|
$allowSimpleLoops = 'false' or
|
||||||
|
(Statement//CursorForLoopStatement or ancestor::CursorForLoopStatement)
|
||||||
|
]
|
||||||
|
/ForIndex[not(matches(@Image, $cursorPattern))]
|
||||||
|
|
|
||||||
|
//ForStatement[
|
||||||
|
$allowSimpleLoops = 'false' or
|
||||||
|
(Statement//ForStatement or ancestor::ForStatement)
|
||||||
|
]
|
||||||
|
/ForIndex[not(matches(@Image, $indexPattern))]
|
||||||
|
```
|
||||||
|
|
||||||
|
**Example(s):**
|
||||||
|
|
||||||
|
``` sql
|
||||||
|
-- good example
|
||||||
|
BEGIN
|
||||||
|
FOR company IN (SELECT * FROM companies) LOOP
|
||||||
|
FOR contact IN (SELECT * FROM contacts) LOOP
|
||||||
|
FOR party IN (SELECT * FROM parties) LOOP
|
||||||
|
NULL;
|
||||||
|
END LOOP;
|
||||||
|
END LOOP;
|
||||||
|
END LOOP;
|
||||||
|
END;
|
||||||
|
/
|
||||||
|
|
||||||
|
-- bad example
|
||||||
|
BEGIN
|
||||||
|
FOR c1 IN (SELECT * FROM companies) LOOP
|
||||||
|
FOR c2 IN (SELECT * FROM contacts) LOOP
|
||||||
|
FOR c3 IN (SELECT * FROM parties) LOOP
|
||||||
|
NULL;
|
||||||
|
END LOOP;
|
||||||
|
END LOOP;
|
||||||
|
END LOOP;
|
||||||
|
END;
|
||||||
|
/
|
||||||
|
```
|
||||||
|
|
||||||
|
**This rule has the following properties:**
|
||||||
|
|
||||||
|
|Name|Default Value|Description|Multivalued|
|
||||||
|
|----|-------------|-----------|-----------|
|
||||||
|
|allowSimpleLoops|false|Ignore simple loops, that are not nested|no|
|
||||||
|
|cursorPattern|[a-zA-Z_0-9]{5,}|The pattern used for the curosr loop variable|no|
|
||||||
|
|indexPattern|[a-zA-Z_0-9]{5,}|The pattern used for the index loop variable|no|
|
||||||
|
|
||||||
|
**Use this rule by referencing it:**
|
||||||
|
``` xml
|
||||||
|
<rule ref="category/plsql/codestyle.xml/ForLoopNaming" />
|
||||||
|
```
|
||||||
|
|
||||||
## MisplacedPragma
|
## MisplacedPragma
|
||||||
|
|
||||||
**Since:** PMD 5.5.2
|
**Since:** PMD 5.5.2
|
||||||
|
Reference in New Issue
Block a user