Quantcast

Enforcing rules using checkstyle

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Enforcing rules using checkstyle

venus
This post has NOT been accepted by the mailing list yet.
I would like to know if the following is possible with Checkstyle:
(a) Enforce the length of the variable names {like if the variable name length is less than 3 characters then a warning should be flagged; similarly any validity is possible in the max length also}
(b) Enforce that the variable does not contain certain permitted characters {like digits, underscore etc.,}
(c) Enforce that the number of lines in a class method is within some threshold limits {say 50 lines per method; if it more a warning should be generated}

If the above things, are possible, what is changes to be done in the config files.  In case if the above is not possible with checkstyle, can I enforce it using pmd or Findbugs or any other open-source tool.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Enforcing rules using checkstyle

java.static.tools
This post has NOT been accepted by the mailing list yet.
all the belo mantioned is posible through checkstyle.
see the links belo
http://checkstyle.sourceforge.net/config_naming.html
in the config file provide as
<module name="ParameterName">
  <property name="format" value="^[a-z][a-zA-Z][a-zA-Z][a-zA-Z]*$"/>
</module>
max permitted length is also possible, using appropriate regex

http://checkstyle.sourceforge.net/config_sizes.html
in the config file provide as
<module name="MethodLength">
   <property name="tokens" value="METHOD_DEF"/>
   <property name="max" value="50"/>
   <property name="countEmpty" value="false"/>
</module>
hope this helps.

i thnk it is passible with pmd also.pls chek in tht forum.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Enforcing rules using checkstyle

venus
This post has NOT been accepted by the mailing list yet.
Thanks for the solution.
I tried these and it works!!!
Loading...