Women in Technology

Hear us Roar



Article:
  Custom PMD Rules
Subject:   PMD CUSTOM XPATH RULE
Date:   2005-02-24 06:09:36
From:   tcopeland
Response to: PMD CUSTOM XPATH RULE

Hi PravinD -


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

Full Threads Newest First

Showing messages 1 through 3 of 3.

  • PMD CUSTOM XPATH RULE
    2005-02-24 22:14:46  PravinD [View]

    Hello Tom,

    Thnaks for the timely help. I will use the rule and let you know. I have a few more queries coming up, so I am gonna keep you a busier man in teh forthcoming days. Just kidding. Thanks a lot mate.

    Cheers,
    Pravin. D
    • PMD CUSTOM XPATH RULE
      2005-02-25 06:04:24  tcopeland [View]

      Hi Pravin -

      Sounds good! But you may want to post questions on the PMD forums:

      http://sourceforge.net/forum/forum.php?forum_id=188192

      A bunch of people monitor those forums, and you may get a faster answer that way...

      Yours,

      Tom
      • PMD CUSTOM XPATH RULE
        2005-02-28 00:09:47  PravinD [View]

        Sure mate. I will do that too. Once again, thanks for the timely help.

        Pravin. D