Checkstyle4nb: Customised formats not working for the Naming Conventions

classic Classic list List threaded Threaded
1 message Options
dts
Reply | Threaded
Open this post in threaded view
|

Checkstyle4nb: Customised formats not working for the Naming Conventions

dts
This post was updated on .
Hello,
I have the following code naming convention requirements using the
checkstyle 4.1 version with Netbeans6.1.

The local variable needs to start with "l_" such as "l_varName" ,
the global variable needs with "m_" such as "m_varName" and
the method parameter needs with "p_" such as "p_parameterName"
conventions.

I find the checkstyle allows the user to change the format for the Naming
Conventions modules
http://checkstyle.sourceforge.net/config_naming.html
which gives an example such as
<module name="MemberName">
<property name="format" value="^m[A-Z][a-zA-Z0-9]*$"/>
</module>

Accordingly, I have made the following changes to the checkstyle-4.0.xml
file based on my required conventions:

<module name="LocalFinalVariableNameCheck">
<property name="format" value="^l\_[a-z][a-zA-Z0-9]*$"/>
<property name="severity" value="warning"/>
</module>

<module name="LocalVariableNameCheck">
<property name="format" value="^l\_[a-z][a-zA-Z0-9]*$"/>
<property name="severity" value="warning"/>
</module>

<module name="MemberNameCheck">
<property name="format" value="^m\_[a-z][a-zA-Z0-9]*$"/>
<property name="severity" value="warning"/>
</module>

<module name="StaticVariableNameCheck">
<property name="format" value="^m\_[a-z][a-zA-Z0-9]*$"/>
<property name="severity" value="warning"/>
</module>

<module name="ParameterNameCheck">
<property name="format" value="^p\_[a-z][a-zA-Z0-9]*$"/>
<property name="severity" value="warning"/>
</module>

While runnnig the checkstyle with the sample "TestConvention.java" file
with these setting, it throws the comments such as
"...TestConvention.java[20]: Name 'm_assetId' must match pattern
'^[a-z][a-zA-Z0-9]*$'. " ,
"...TestConvention.java[25]: Name 'm_clipBankTaxonomyTree' must match
pattern '^[a-z][a-zA-Z0-9]*$'. ",
"...TestConvention.java[46]: Name 'p_clipBankTaxonomyTreeOfAssetMgr' must
match pattern '^[a-z][a-zA-Z0-9]*$'. ",
"...TestConvention.java[48]: Name 'l_assetMgrTaxonomyTreeNodes' must
match pattern '^[a-z][a-zA-Z0-9]*$'. ".

I find this as a bug as the above customized formats are not taking into
consideration..
A sample java file which is used to check for the conventions is
attached.

Kindly do the needful.

Thanks in advance,
DilipTestConvention.java