Women in Technology

Hear us Roar



Article:
  Custom PMD Rules
Subject:   Few More Rules Pls
Date:   2005-04-11 02:40:09
From:   PravinD
Hey Tom,


Hope you doing good. I actually need your help to write a couple of more rules using XPath. I am not able to get them working rite. The following are the conditions that I want to check using XPath rules:


1) Rule that checks for open ResultSets, Statements, PreparedStatements and also ensures that these are closed only in the finally block.


2) Rule to ensure rollback statements are surrounded in a try/catch block.


3) Rule to check Naiming Conventions for PreparedStatement,Statement,ResultSet,CallableStatement. ie. Prepared Statements should start only with the letters 'pstmt'etc. (I have written a rule for this already and it works fine. So you might want to skip this)


4) Rule to check the length of variables such that it does not exceed 25 characters.


Kindly give me the rules if you can.


Cheers,
Pravin. D

Full Threads Newest First

Showing messages 1 through 3 of 3.

  • Few More Rules Pls
    2005-04-11 06:05:45  tcopeland [View]

    Hi Pravin -

    Cool, let me post an answer to your post over on the PMD forums:

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

    Yours,

    Tom
    • Few More Rules Pls
      2005-04-11 07:27:43  PravinD [View]

      Oh okie! Shall check the thread in the pmd forums. Once again, Thanks mate!

      Regards,
      Pravin. D
    • Null check for an object
      2006-03-21 23:04:26  PravinD [View]

      please help me in writing the rule for the following scenario:

      Before invoking any method of an object, a null check should be done.

      Eg:

      String str1 = null;
      String str2 = "ASP";

      str2 = str1.toUpperCase(); // Which will throw NullPointerException.

      So I have to ensure that this line is in the if check. Like,

      String str1 = null;
      String str2 = "ASP";

      if(str1 != null)
      {
      str2 = str1.toUpperCase();
      }

      Any help would be appreciated. Which would be better a Java rule or XPATH rule?