Article:
 |
|
Custom PMD Rules
|
| Subject: |
|
PMD CUSTOM XPATH RULE |
| Date: |
|
2005-02-24 01:18:45 |
| From: |
|
PravinD
|
|
|
|
I am attempting to create a couple of PMD rules.
1) To create a rule that checks for the occurences of String objects and throws a warning if the names of the objects do not start with the letters 'str'
2) To create a rule that checks for open connection objects and throws a warning if these objects remain unclosed.
Can someone help me on this or post the xpath rule for the same?
|
Showing messages 1 through 4 of 4.
-
PMD CUSTOM XPATH RULE
2005-02-24 06:09:36
tcopeland
[View]
-
PMD CUSTOM XPATH RULE
2005-02-24 22:14:46
PravinD
[View]
-
PMD CUSTOM XPATH RULE
2005-02-25 06:04:24
tcopeland
[View]
-
PMD CUSTOM XPATH RULE
2005-02-28 00:09:47
PravinD
[View]
Cool, OK, let's see:
> occurences of String objects and throws a
> warning if the names of the objects do not
> start with the letters 'str'
Hm. The XPath rule below will catch field declarations of Strings that don't start with "str":
//FieldDeclaration
[
Type/Name[@Image='String']
and not(starts-with(VariableDeclarator/VariableDeclaratorId/@Image, 'str'))
]
and you can write similar ones for parameters and local variable declarations.
> checks for open connection objects and
> throws a warning if these objects remain
> unclosed.
Check out the CloseConnection rule here:
http://pmd.sourceforge.net/rules/design.html
Yours,
Tom