All Downloads are FREE. Search and download functionalities are using the official Maven repository.

hudson.plugins.checkstyle.rules.config_naming.xml Maven / Gradle / Ivy

Go to download

This plug-in generates the trend report for Checkstyle, an open source static code analysis program.

There is a newer version: 3.12
Show newest version
<?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">&#39;m&#39;</span>, followed
        by an upper case letter, and then letters and digits:
      </p>
      
      <source>
&lt;module name=&quot;MemberName&quot;&gt;
  &lt;property name=&quot;format&quot; value=&quot;^m[A-Z][a-zA-Z0-9]*$&quot;/&gt;
&lt;/module&gt;
      </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>
&lt;module name=&quot;PackageName&quot;&gt;
    &lt;property name=&quot;format&quot;
              value=&quot;^[a-z]+(\.[a-z][a-z0-9]*)*$&quot;/&gt;
&lt;/module&gt;
      </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>
&lt;module name=&quot;LocalVariableName&quot;&gt;
    &lt;property name=&quot;format&quot; value=&quot;^e[a-zA-Z0-9]*$&quot;/&gt;
    &lt;property name=&quot;tokens&quot; value=&quot;PARAMETER_DEF&quot;/&gt;
&lt;/module&gt;
      </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>
&lt;module name=&quot;TypeName&quot;&gt;
    &lt;property name=&quot;format&quot;
              value=&quot;^I_[a-zA-Z0-9]*$&quot;/&gt;
    &lt;property name=&quot;tokens&quot;
              value=&quot;INTERFACE_DEF&quot;/&gt;
&lt;/module&gt;
      </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