
hudson.plugins.checkstyle.rules.config_naming.xml Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of checkstyle Show documentation
Show all versions of checkstyle Show documentation
This plug-in generates the trend report for
Checkstyle, an open source static code analysis program.
<?xml version="1.0" encoding="ISO-8859-1"?> <document> <properties> <title>Naming Conventions</title> <author>Checkstyle Development Team</author> </properties> <body> <section name="Overview"> <p> Each of these naming modules validates identifiers for particular code elements. Valid identifiers for a naming module are specified by its <span class="code"> format</span> property. The value of <span class="code">format</span> is a <a href="http://jakarta.apache.org/regexp/">regular expression</a> for valid identifiers. This is an example of a configuration of the <span class="code">MemberName</span> module to ensure that member identifiers begin with <span class="code">'m'</span>, followed by an upper case letter, and then letters and digits: </p> <source> <module name="MemberName"> <property name="format" value="^m[A-Z][a-zA-Z0-9]*$"/> </module> </source> <p> All naming modules belong to package <span class="code">com.puppycrawl.tools.checkstyle.checks.naming</span> and are submodules of <a href="config.html#treewalker"><span class="code">TreeWalker</span></a>. </p> </section> <section name="Modules"> <table> <tr> <th>module</th> <th>validates identifiers for</th> <th>default value of <span class="code">format</span></th> </tr> <tr> <td><span class="code">AbstractClassName</span></td> <td><span class="code">abstract</span> classes</td> <td><span class="default">^Abstract.*$|^.*Factory$</span></td> </tr> <tr> <td><span class="code">ConstantName</span></td> <td> constants (<span class="code">static</span>, <span class="code"> final</span> fields) </td> <td><span class="default">^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$</span></td> </tr> <tr> <td><span class="code">LocalFinalVariableName</span></td> <td>local, <span class="code">final</span> variables, including <span class="code">catch</span> parameters</td> <td><span class="default">^[a-z][a-zA-Z0-9]*$</span></td> </tr> <tr> <td><span class="code">LocalVariableName</span></td> <td> local, non-<span class="code">final</span> variables, including <span class="code">catch</span> parameters </td> <td><span class="default">^[a-z][a-zA-Z0-9]*$</span></td> </tr> <tr> <td><span class="code">MemberName</span></td> <td>non-<span class="code">static</span> fields</td> <td><span class="default">^[a-z][a-zA-Z0-9]*$</span></td> </tr> <tr> <td><span class="code">MethodName</span></td> <td>methods</td> <td><span class="default">^[a-z][a-zA-Z0-9]*$</span></td> </tr> <tr> <td><span class="code">PackageName</span></td> <td>packages</td> <td> <span class="default">^[a-z]+(\.[a-zA-Z_][a-zA-Z0-9_]*)*$</span> </td> </tr> <tr> <td><span class="code">ParameterName</span></td> <td>parameters</td> <td><span class="default">^[a-z][a-zA-Z0-9]*$</span></td> </tr> <tr> <td><span class="code">StaticVariableName</span></td> <td> <span class="code">static</span>, non-<span class="code">final</span> fields </td> <td><span class="default">^[a-z][a-zA-Z0-9]*$</span></td> </tr> <tr> <td><span class="code">TypeName</span></td> <td>classes and interfaces</td> <td><span class="default">^[A-Z][a-zA-Z0-9]*$</span></td> </tr> </table> </section> <section name="Notes"> <p> The default value of <span class="code">format</span> for module <span class="code">PackageName</span> has been chosen to match the requirements in the <a href="http://java.sun.com/docs/books/jls/second_edition/html/packages.doc.html#40169">Java Language specification</a> and the Sun coding conventions. However both underscores and uppercase letters are rather uncommon, so most configurations should probably assign value <span class="code">^[a-z]+(\.[a-z][a-z0-9]*)*$</span> to <span class="code">format</span> for module <span class="code">PackageName</span>, as in </p> <source> <module name="PackageName"> <property name="format" value="^[a-z]+(\.[a-z][a-z0-9]*)*$"/> </module> </source> <p> Module <span class="code">LocalVariableName</span> also has property <span class="code">tokens</span> which can be used to control whether the check applies to variable declarations or <span class="code">catch</span> clause parameters through tokens <span class="code">VARIABLE_DEF</span> and <span class="code">PARAMETER_DEF</span>. For example, the following configuration element ensures that <span class="code">catch</span> clause parameters begin with <span class="code">"e"</span>, followed by letters and digits: </p> <source> <module name="LocalVariableName"> <property name="format" value="^e[a-zA-Z0-9]*$"/> <property name="tokens" value="PARAMETER_DEF"/> </module> </source> <p> Module <span class="code">TypeName</span> also has property <span class="code">tokens</span> which can be used to control whether the check applies to classes or interfaces through tokens <span class="code">CLASS_DEF</span> and <span class="code">INTERFACE_DEF</span>. For example, the following configuration element ensures that interface names begin with <span class="code">"I_"</span>, followed by letters and digits: </p> <source> <module name="TypeName"> <property name="format" value="^I_[a-zA-Z0-9]*$"/> <property name="tokens" value="INTERFACE_DEF"/> </module> </source> <p> Module <span class="code">MemberName</span> also has the following properties: </p> <table> <tr> <th>name</th> <th>description</th> <th>type</th> <th>default value</th> </tr> <tr> <td>applyToPublic</td> <td>Controls whether to apply the check to public member.</td> <td><a href="property_types.html#boolean">Boolean</a></td> <td><span class="default">true</span></td> </tr> <tr> <td>applyToProtected</td> <td>Controls whether to apply the check to protected member.</td> <td><a href="property_types.html#boolean">Boolean</a></td> <td><span class="default">true</span></td> </tr> <tr> <td>applyToPackage</td> <td> Controls whether to apply the check to package-private member. </td> <td><a href="property_types.html#boolean">Boolean</a></td> <td><span class="default">true</span></td> </tr> <tr> <td>applyToPrivate</td> <td>Controls whether to apply the check to pribvate member.</td> <td><a href="property_types.html#boolean">Boolean</a></td> <td><span class="default">true</span></td> </tr> </table> </section> </body> </document>
© 2015 - 2025 Weber Informatics LLC | Privacy Policy