Not needed anymore

This commit is contained in:
Oliver Burn 2004-12-05 06:46:13 +00:00
parent aa78210274
commit 7ae44527dd
34 changed files with 0 additions and 11046 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -1,276 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Checkstyle ANT Task - Version @CHECKSTYLE_VERSION@</title>
<link rel="stylesheet" type="text/css" href="mystyle.css"/>
</head>
<body>
<h1><a name="checkstyle">Checkstyle ANT Task - Version @CHECKSTYLE_VERSION@</a></h1>
<h3>Description</h3>
<p>This task runs Checkstyle over specified Java files. The task has been tested using ANT 1.5.
The latest version of checkstyle can be found at <a href="http://checkstyle.sourceforge.net/">http://checkstyle.sourceforge.net/</a>.
This task is included in the checkstyle distribution.</p>
<h3>Installation</h3>
<p>The easiest way is to include <span class="default">checkstyle-all-@CHECKSTYLE_VERSION@.jar</span> in the classpath. This contains all the classes required to run Checkstyle. Alternatively, you must include the following in the classpath:</p>
<ol>
<li><span class="default">checkstyle-@CHECKSTYLE_VERSION@.jar</span></li>
<li>ANTLR 2.7.2 classes. <span class="default">antlr.jar</span> is included in the distribution.</li>
<li>Jakarta Regexp 1.3 classes. <span class="default">jakarta-regexp-1.3.jar</span> is included in the distribution.</li>
<li>Jakarta Commons Beanutils classes. <span class="default">commons-beanutils.jar</span> is included in the distribution.</li>
<li>Jakarta Commons Collections classes. <span class="default">commons-collections.jar</span> is included in the distribution.</li>
<li>Jakarta Commons Logging classes. <span class="default">commons-logging.jar</span> is included in the distribution.</li>
<li>A JAXP compliant XML parser implementation. You already have it on your system if you run ANT or JDK 1.4.</li>
</ol>
<p>To use the task in a build file, you will need the following
<code>taskdef</code> declaration:</p>
<pre>
&lt;taskdef resource=&quot;checkstyletask.properties&quot;
classpath=&quot;/path/to/checkstyle-all-@CHECKSTYLE_VERSION@.jar&quot;/&gt;
</pre>
<p>Or, assuming that Checkstyle is in the global classpath (not recommended),
then you will need the following <code>taskdef</code> declaration:</p>
<pre>
&lt;taskdef resource=&quot;checkstyletask.properties&quot;/&gt;
</pre>
<h3>Parameters</h3>
<table border="1" cellpadding="2" cellspacing="0" summary="parameters">
<tr class="header">
<td><b>Attribute</b></td>
<td><b>Description</b></td>
<td><b>Required</b></td>
</tr>
<tr>
<td>file</td>
<td>File to run checkstyle on.</td>
<td class="required">One of either <i>file</i> or at least one nested <i>fileset</i> element</td>
</tr>
<tr>
<td>config</td>
<td>Specifies a file that defines the configuration modules.
<a href="config.html">See here</a> for a description of how to define a configuration.</td>
<td class="required">Exactly one of config or configURL</td>
</tr>
<tr>
<td>configURL</td>
<td>Specifies a URL that defines the configuration modules.
<a href="config.html">See here</a> for a description of how to define a configuration.</td>
<td class="required">Exactly one of config or configURL</td>
</tr>
<tr>
<td>properties</td>
<td>
Specifies a file that contains properties for <a href="config.html#properties">
expanded property values</a> of the configuration.
Ant properties (like ${basedir}) and nested property elements override
the properties in this file.
</td>
<td class="required">No</td>
</tr>
<tr>
<td>packageNamesFile</td>
<td>
Specifies a file that contains <a href="config.html#packagenames">
package names</a> for the configuration.
</td>
<td class="required">No</td>
</tr>
<tr>
<td>failOnViolation</td>
<td>Specifies whether the build will continue even if there are violations.
Defaults to <span class="default">&quot;true&quot;</span>.</td>
<td class="required">No</td>
</tr>
<tr>
<td>failureProperty</td>
<td>The name of a property to set in the event of a violation.</td>
<td class="required">No</td>
</tr>
<tr>
<td>maxErrors</td>
<td>The maximum number of errors that are tolerated before breaking
the build or setting the failure property. Defaults to
<span class="default">&quot;0&quot;</span>.</td>
<td class="required">No</td>
</tr>
<tr>
<td>maxWarnings</td>
<td>The maximum number of warnings that are tolerated before breaking
the build or setting the failure property. Defaults to
<span class="default">&quot;2147483647&quot;</span>, i.e.
<a href="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Integer.html#MAX_VALUE">Integer.MAX_VALUE</a>.</td>
<td class="required">No</td>
</tr>
<tr>
<td>classpath</td>
<td>The classpath to use when looking up classes. Defaults to the current classpath.</td>
<td class="required">No</td>
</tr>
<tr>
<td>classpathref</td>
<td>The classpath to use when looking up classes, given as a reference
to a path defined elsewhere.</td>
<td class="required">No</td>
</tr>
</table>
<h3>Nested Elements</h3>
<p>This task supports the nested elements
<a href="http://ant.apache.org/manual/CoreTypes/fileset.html">&lt;fileset&gt;</a>,
<a href="http://ant.apache.org/manual/using.html#path">&lt;classpath&gt;</a>,
<span class="default">&lt;formatter&gt;</span>, and
<span class="default">&lt;property&gt;</span>.</p>
<p>The parameters for the <span class="default">&lt;formatter&gt;</span> element are:</p>
<table border="1" cellpadding="2" cellspacing="0" summary="nested elements">
<tr class="header">
<td><b>Attribute</b></td>
<td><b>Description</b></td>
<td><b>Required</b></td>
</tr>
<tr>
<td>type</td>
<td>
<p>The type of output to generate. The valid values are:</p>
<ul>
<li><span class="default">plain</span> - specifies the <a href="api/com/puppycrawl/tools/checkstyle/DefaultLogger.html">DefaultLogger</a></li>
<li><span class="default">xml</span> - specifies the <a href="api/com/puppycrawl/tools/checkstyle/XMLLogger.html">XMLLogger</a></li>
</ul>
<p>Defaults to <span class="default">"plain"</span>.</p>
</td>
<td class="required">No</td>
</tr>
<tr>
<td>toFile</td>
<td>The file to write output to. Defaults to standard output. Note, there is no way to explicitly specify standard output.
</td>
<td class="required">No</td>
</tr>
</table>
<p>A <span class="default">&lt;property&gt;</span> element provides a property for
<a href="config.html#properties">expanded property values</a> of the configuration.
The parameters for the <span class="default">&lt;property&gt;</span> element are:</p>
<table border="1" cellpadding="2" cellspacing="0" summary="nested elements">
<tr class="header">
<td><b>Attribute</b></td>
<td><b>Description</b></td>
<td><b>Required</b></td>
</tr>
<tr>
<td>key</td>
<td><p>The key for the property.</p></td>
<td class="required">Yes</td>
</tr>
<tr>
<td>value</td>
<td>The value of the property specified as a string.</td>
<td class="required">Either <i>value</i> or <i>file</i></td>
</tr>
<tr>
<td>file</td>
<td>The value of the property specified as a file. This is
great for specifying file names relative to the ANT build file.</td>
<td class="required">Either <i>value</i> or <i>file</i></td>
</tr>
</table>
<h3>Examples</h3>
<p><b>Run checkstyle with configuration file <code>docs/sun_checks.xml</code> on a single file</b></p>
<pre>
&lt;checkstyle config=&quot;docs/sun_checks.xml&quot; file=&quot;Check.java&quot;/&gt;
</pre>
<p><b>Run checkstyle on a set of Java files using site-wide configuration and
an expanded property value</b></p>
<pre>
&lt;checkstyle config=&quot;/path/to/site/sun_checks.xml&quot;&gt;
&lt;fileset dir=&quot;src/checkstyle&quot; includes=&quot;**/*.java&quot;/&gt;
&lt;!-- Location of cache-file. Something that is project specific --&gt;
&lt;property key=&quot;checkstyle.cache.file&quot; file=&quot;target/cachefile&quot;/&gt;
&lt;/checkstyle&gt;
</pre>
<p><b>Run checkstyle on a set of files and output messages to standard output in plain format, and a file in XML format</b></p>
<pre>
&lt;checkstyle config=&quot;docs/sun_checks.xml&quot;&gt;
&lt;fileset dir=&quot;src/checkstyle&quot; includes=&quot;**/*.java&quot;/&gt;
&lt;formatter type=&quot;plain&quot;/&gt;
&lt;formatter type=&quot;xml&quot; toFile=&quot;build/checkstyle_errors.xml&quot;/&gt;
&lt;/checkstyle&gt;
</pre>
<p>
<b>Run checkstyle with configuration file <code>docs/sun_checks.xml</code> on a file and
provide a package names file</b>
</p>
<pre>
&lt;checkstyle config=&quot;docs/sun_checks.xml&quot;
packageNamesFile=&quot;myPackageNames.xml&quot;
file=&quot;Check.java&quot;/&gt;
</pre>
<p>
<p><b>Run checkstyle in an automated build and send an email report if style violations are detected</b></p>
<pre>
&lt;target name=&quot;checkstyle&quot;
description=&quot;Generates a report of code convention violations.&quot;>
&lt;checkstyle config=&quot;docs/sun_checks.xml&quot;
failureProperty=&quot;checkstyle.failure&quot;
failOnViolation=&quot;false&quot;&gt;
&lt;formatter type=&quot;xml&quot; tofile=&quot;checkstyle_report.xml&quot;/&gt;
&lt;fileset dir=&quot;src&quot; includes=&quot;**/*.java&quot;/&gt;
&lt;/checkstyle&gt;
&lt;style in=&quot;checkstyle_report.xml&quot; out=&quot;checkstyle_report.html&quot; style=&quot;checkstyle.xsl&quot;/&gt;
&lt;/target&gt;
&lt;!-- run this target as part of automated build --&gt;
&lt;target name=&quot;checkstyle-nightly&quot;
depends=&quot;checkstyle&quot;
if=&quot;checkstyle.failure&quot;
description=&quot;Sends email if checkstyle detected code conventions violations.&quot;&gt;
&lt;!-- use your own server and email addresses below. See Ant documentation for details --&gt;
&lt;mail from=&quot;qa@some.domain&quot;
tolist=&quot;someone@some.domain,someoneelse@some.domain&quot;
mailhost=&quot;mailbox.some.domain&quot;
subject=&quot;Checkstyle violation(s) in project ${ant.project.name}&quot;
files=&quot;checkstyle_report.html&quot;/&gt;
&lt;/target&gt;
</pre>
<hr />
<p class="copyright">Copyright &copy; 2002-2004 Oliver Burn. All rights Reserved.</p>
</body>
</html>

View File

@ -1,4 +0,0 @@
com
*.html
*.css
package-list

View File

@ -1,137 +0,0 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.2//EN"
"http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
<module name="Checker">
<metadata name="com.atlas-sw.eclipse" value="I like Sydney"/>
<property name="severity" value="error"/>
<module name="SuppressionFilter">
<property name="file" value="${checkstyle.suppressions.file}"/>
</module>
<module name="PackageHtml"/>
<module name="Translation">
<property name="severity" value="${translation.severity}"/>
</module>
<module name="TreeWalker">
<property name="tabWidth" value="4" />
<module name="GenericIllegalRegexp">
<property name="format" value="\s$"/>
</module>
<module name="AvoidStarImport"/>
<module name="ConstantName"/>
<module name="EmptyBlock"/>
<module name="EmptyForIteratorPad"/>
<module name="EqualsHashCode"/>
<module name="FileLength" />
<module name="Header">
<property name="headerFile" value="${checkstyle.header.file}"/>
</module>
<module name="IllegalImport"/>
<module name="IllegalInstantiation"/>
<module name="InnerAssignment"/>
<module name="JavadocType">
<property name="authorFormat" value="\S"/>
</module>
<module name="JavadocMethod">
<property name="allowUndeclaredRTE" value="true"/>
<property name="allowThrowsTagsForSubclasses" value="true"/>
</module>
<module name="JavadocVariable"/>
<module name="JavadocStyle">
<property name="scope" value="public"/>
</module>
<module name="LeftCurly">
<property name="tokens" value="CLASS_DEF,INTERFACE_DEF,METHOD_DEF,CTOR_DEF"/>
<property name="option" value="nl"/>
</module>
<module name="LeftCurly">
<property name="tokens" value="LITERAL_CATCH,LITERAL_DO,LITERAL_ELSE,LITERAL_FINALLY,LITERAL_FOR,LITERAL_IF,LITERAL_SWITCH,LITERAL_SYNCHRONIZED,LITERAL_TRY,LITERAL_WHILE"/>
<property name="option" value="nlow"/>
</module>
<module name="LineLength">
<property name="ignorePattern" value="^ *\* *[^ ]+$"/>
</module>
<module name="LocalFinalVariableName"/>
<module name="LocalVariableName"/>
<module name="MemberName">
<property name="format" value="^m[A-Z][a-zA-Z0-9]*$"/>
</module>
<module name="MethodLength"/>
<module name="MethodName"/>
<module name="MethodParamPad"/>
<module name="ModifierOrder"/>
<module name="NeedBraces"/>
<module name="NoWhitespaceAfter"/>
<module name="NoWhitespaceBefore"/>
<module name="NoWhitespaceBefore">
<property name="tokens" value="DOT"/>
<property name="allowLineBreaks" value="true"/>
</module>
<module name="OperatorWrap"/>
<module name="OperatorWrap">
<property name="tokens" value="ASSIGN, DIV_ASSIGN, PLUS_ASSIGN, MINUS_ASSIGN, STAR_ASSIGN, MOD_ASSIGN, SR_ASSIGN, BSR_ASSIGN, SL_ASSIGN, BXOR_ASSIGN, BOR_ASSIGN, BAND_ASSIGN"/>
<property name="option" value="eol"/>
</module>
<module name="PackageName"/>
<module name="ParameterName">
<property name="format" value="^a[A-Z][a-zA-Z0-9]*$"/>
</module>
<module name="ParameterNumber"/>
<module name="ParenPad"/>
<module name="TypecastParenPad"/>
<module name="RedundantImport"/>
<module name="RedundantModifier"/>
<module name="RightCurly">
<property name="option" value="alone"/>
</module>
<module name="SimplifyBooleanExpression"/>
<module name="SimplifyBooleanReturn"/>
<module name="StaticVariableName">
<property name="format" value="^s[A-Z][a-zA-Z0-9]*$"/>
</module>
<module name="TabCharacter"/>
<module name="TypeName"/>
<module name="UnusedImports"/>
<module name="UpperEll"/>
<module name="VisibilityModifier"/>
<module name="WhitespaceAfter"/>
<module name="WhitespaceAround"/>
<module name="FinalClass"/>
<module name="MissingSwitchDefault"/>
<module name="MagicNumber"/>
<module name="Indentation">
<property name="basicOffset" value="4"/>
<property name="braceAdjustment" value="0"/>
<property name="caseIndent" value="0"/>
</module>
<module name="ArrayTrailingComma"/>
<!-- module name="FinalLocalVariable"/ -->
<!-- Generates quite a few errors -->
<module name="CyclomaticComplexity">
<property name="severity" value="ignore"/>
</module>
<module name="NestedIfDepth">
<property name="max" value="3"/>
</module>
<module name="NestedTryDepth"/>
<module name="ExplicitInitialization"/>
</module>
</module>

View File

@ -1,161 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Checkstyle Command Line - Version @CHECKSTYLE_VERSION@</title>
<link rel="stylesheet" type="text/css" href="mystyle.css"/>
</head>
<body>
<h1><a name="checkstyle">Checkstyle Command Line - Version @CHECKSTYLE_VERSION@</a></h1>
<h2>Description</h2>
<p>
This document describes how to run checkstyle using the command line tool. The
latest version of checkstyle can be found at <a href="http://checkstyle.sourceforge.net">http://checkstyle.sourceforge.net</a>.
This command line tool is included in the checkstyle distribution.
</p>
<h2>Installation</h2>
<p>
The easiest way is to include <span class="default">checkstyle-all-@CHECKSTYLE_VERSION@.jar</span> in the classpath. If you are running JDK 1.4 this contains all the classes required to run checkstyle (JDK 1.3 users must add a JAXP compliant XML parser implementation). Alternatively, you must include the following in the classpath:
</p>
<ol>
<li><span class="default">checkstyle-@CHECKSTYLE_VERSION@.jar</span></li>
<li>ANTLR 2.7.2 classes. <span class="default">antlr.jar</span> is included in the distribution.</li>
<li>Jakarta Regexp 1.3 classes. <span class="default">jakarta-regexp-1.3.jar</span> is included in the distribution.</li>
<li>Jakarta Commons Beanutils classes. <span class="default">commons-beanutils.jar</span> is included in the distribution.</li>
<li>Jakarta Commons Collections classes. <span class="default">commons-collections.jar</span> is included in the distribution.</li>
<li>Jakarta Commons Logging classes. <span class="default">commons-logging.jar</span> is included in the distribution.</li>
<li>Jakarta Commons CLI (command line interface) classes. <span class="default">commons-cli.jar</span> is included in the distribution.</li>
<li>JDK 1.3 only: A JAXP compliant XML parser implementation.</li>
</ol>
<h2>Usage</h2>
<p>
The command line usage is:
</p>
<pre>
java -D&lt;property&gt;=&lt;value&gt; \
com.puppycrawl.tools.checkstyle.Main \
-c &lt;configurationFile&gt; [-n &lt;packageNameFile&gt;] \
[-f &lt;format&gt;] [-p &lt;propertiesFile&gt;] [-o &lt;file&gt;] \
[-r &lt;dir&gt;] file...
</pre>
<p>
Checkstyle will process the specified files and by default report errors to
standard out in plain format. Checkstyle requires a <a href="config.html">configuration XML file</a> that configures the
checks to apply. Command line options are:
</p>
<ul>
<li>
<span class="default">-n packageNamesFile</span> - specify a
<a href="config.html#packagenames">package names file</a> to use.
</li>
<li>
<span class="default">-f format</span> - specify the output format. Options are <span class="default">
"plain"</span> for the <a href="api/com/puppycrawl/tools/checkstyle/DefaultLogger.html">DefaultLogger</a>
and <span class="default">"xml"</span> for the <a href="api/com/puppycrawl/tools/checkstyle/XMLLogger.html">XMLLogger</a>.
Defaults to <span class="default">"plain"</span>.
</li>
<li>
<span class="default">-p propertiesFile</span> - specify a properties file to
use.
</li>
<li>
<span class="default">-o file</span> - specify the file to output to.
</li>
<li>
<span class="default">-r dir</span> - specify the directory to traverse for Java
source files.
</li>
</ul>
<p>
Set the properties for <a href="config.html#properties">expanded property values</a>
by either by assigning system
properties using the <code>-D&lt;property&gt;=&lt;value&gt;</code> arguments to
java or specifying a property file using the <code>-p</code> option.
If a property file is specified, the system properties are ignored.
</p>
<h2>Examples</h2>
<p>
<b>Run checkstyle with configuration file <code>docs/sun_checks.xml</code> on a file</b>
</p>
<pre>
java com.puppycrawl.tools.checkstyle.Main -c docs/sun_checks.xml \
Check.java
</pre>
<p>
<b>Run checkstyle with configuration file <code>docs/sun_checks.xml</code>
on all java files in a directory</b>
</p>
<pre>
java com.puppycrawl.tools.checkstyle.Main -c docs/sun_checks.xml \
-r src/
</pre>
<p>
<b>Run checkstyle with configuration file <code>docs/sun_checks.xml</code>
on a file and provide a system property</b>
</p>
<pre>
java -Dcheckstyle.cache.file=target/cachefile \
com.puppycrawl.tools.checkstyle.Main -c docs/sun_checks.xml \
Check.java
</pre>
<p>
<b>Run checkstyle with configuration file <code>docs/sun_checks.xml</code>
on a file and use properties in a file</b>
</p>
<pre>
java com.puppycrawl.tools.checkstyle.Main -c docs/sun_checks.xml \
-p myCheckstyle.properties Check.java
</pre>
<p>
<b>Run checkstyle with configuration file <code>docs/sun_checks.xml</code>
on a file and output to a file in XML format </b>
</p>
<pre>
java com.puppycrawl.tools.checkstyle.Main -c docs/sun_checks.xml \
-f xml -o build/checkstyle_errors.xml Check.java
</pre>
<p>
<b>Run checkstyle with configuration file <code>docs/sun_checks.xml</code> on a file and
provide a package names file</b>
</p>
<pre>
java com.puppycrawl.tools.checkstyle.Main -c docs/sun_checks.xml \
-n myPackageNames.xml Check.java
</pre>
<div class="tip">
<h4 class="tip">Tip</h4>
<p>
It is possible to run Checkstyle directly from the JAR file using the
<span class="code">-jar</span> option. An example would be:
</p>
<pre>
java -jar checkstyle-all-@CHECKSTYLE_VERSION@.jar \
-c docs/sun_checks.xml Check.java
</pre>
</div>
<hr />
<div><a href="index.html">Back to the Checkstyle Home Page</a></div>
<p class="copyright">Copyright &copy; 2002-2004 Oliver Burn. All rights Reserved.</p>
</body>
</html>

View File

@ -1,992 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Checkstyle Configuration</title>
<link rel="stylesheet" type="text/css" href="mystyle.css"/>
</head>
<body>
<!-- The header -->
<table border="0" width="100%" summary="header layout">
<tr>
<td><h1>Checkstyle Configuration</h1></td>
<td align="right"><img src="logo.png" alt="Checkstyle Logo"/></td>
</tr>
</table>
<!-- content -->
<table border="0" width="100%" cellpadding="5" summary="body layout">
<tr>
<!--Left menu-->
<td class="menu" valign="top">
<ul>
<li>
<a href="#overview">Overview</a>
</li>
<li>
<a href="#modules">Modules</a>
</li>
<li>
<a href="#properties">Properties</a>
</li>
<li>
<a href="#checker">Checker</a>
</li>
<li>
<a href="#treewalker">TreeWalker</a>
</li>
<li>
<a href="#treewalkerchecks">TreeWalker Checks</a>
</li>
<li>
<a href="#severity">Severity</a>
</li>
<li>
<a href="#filters">Filters</a>
</li>
<li>
<a href="#auditlisteners">AuditListeners</a>
</li>
<li>
<a href="#packagenames">Packages</a>
</li>
<li>
<a href="#xml">XML Details</a>
</li>
</ul>
</td>
<!--Content-->
<td class="content" valign="top" align="left">
<a name="overview"></a> <h2>Overview</h2>
<p class="body">
A Checkstyle configuration specifies which <em>modules</em> to plug in and apply to Java
source files. Modules are structured in a tree whose root is the <em>Checker</em>
module. The next level of modules contains
</p>
<ul class="body">
<li><em>FileSetChecks</em>- modules that take a set of input files and fire error messages.</li>
<li><em>Filters</em>- modules that filter audit events, including error messages, for acceptance.</li>
<li><em>AuditListeners</em>- modules that report accepted events.</li>
</ul>
<p class="body">
Many checks are submodules of
the <em>TreeWalker</em> FileSetCheck module. The TreeWalker operates by
separately transforming each of the Java source files into an abstract syntax
tree and then handing the result over to each of its submodules which in turn
have a look at certain aspects of the tree.
</p>
<p class="body">
Checkstyle obtains a configuration from an XML document whose elements specify
the configuration's hierarchy of modules and their properties. You provide
a file that contains the configuration document when you invoke Checkstyle at
the <a href="cmdline.html">command line</a>, and when you run a <a href="anttask.html">Checkstyle
task</a> in ant. The documentation directory of the Checkstyle distribution contains
a sample configuration file <em>sun_checks.xml</em> which configures Checkstyle
to check for the Sun coding conventions.
</p>
<a name="modules"></a> <h2>Modules</h2>
<p class="body">
A <span class="code">module</span> element in the configuration XML document
specifies a module identified by the element's <span class="code">name</span>
attribute.
</p>
<p class="body">
Here is a fragment of a typical configuration document:
</p>
<pre class="body">
&lt;module name=&quot;Checker&quot;&gt;
&lt;module name=&quot;PackageHtml&quot;/&gt;
&lt;module name=&quot;TreeWalker&quot;&gt;
&lt;module name=&quot;AvoidStarImport&quot;/&gt;
&lt;module name=&quot;ConstantName&quot;/&gt;
&lt;module name=&quot;EmptyBlock&quot;/&gt;
&lt;/module&gt;
&lt;/module&gt;
</pre>
<p class="body">
In this configuration:
</p>
<ul class="body">
<li>
Root module <span class="code">Checker</span> has child FileSetChecks <span class="code">
PackageHtml</span> and <span class="code">TreeWalker</span>. (Module <a href="config_javadoc.html">
<span class="code">PackageHtml</span></a> checks that all packages have package
documentation.)
</li>
<li>
Module <span class="code">TreeWalker</span> has submodules
<span class="code">AvoidStarImport</span>,
<span class="code">ConstantName</span>, and
<span class="code">EmptyBlock</span>.
(Modules
<a href="config_import.html"><span class="code">AvoidStarImport</span></a>,
<a href="config_naming.html"><span class="code">ConstantName</span></a>, and
<a href="config_blocks.html"><span class="code">EmptyBlock</span></a>
check that a Java source file has no star imports, has
valid constant names, and has no empty blocks, respectively.)
</li>
</ul>
<p class ="body">
For each configuration module, Checkstyle loads a class identified by the
<span class="code">name</span> attribute of the <span class="code">module</span>.
There are several rules for loading a module's class:
</p>
<ol class="body">
<li>
Load a class directly according to a package-qualified <span class="code">name</span>,
such as loading class <span class="code">com.puppycrawl.tools.checkstyle.TreeWalker</span>
for element
<pre class="body">
&lt;module name=&quot;com.puppycrawl.tools.checkstyle.TreeWalker&quot;&gt;
</pre>
This is useful for plugging third-party modules into a configuration.
</li>
<li>
Load a class of a pre-specified package, such as loading class
<span class="code">com.puppycrawl.tools.checkstyle.checks.AvoidStarImport</span>
for element
<pre class="body">
&lt;module name=&quot;AvoidStarImport&quot;/&gt;
</pre>
Checkstyle applies packages <span class="code">
com.puppycrawl.tools.checkstyle</span>, <span class="code">
com.puppycrawl.tools.checkstyle.filters</span>, and <span class="code">
com.puppycrawl.tools.checkstyle.checks</span> and its sub-packages (only
those included in the Checkstyle distribution). You can specify other
packages in a <a href="#packagenames"><em>package names XML document</em></a>
when you invoke Checkstyle at the <a href="cmdline.html">command line</a>,
and when you run a <a href="anttask.html">Checkstyle task</a> in ant.
</li>
<li>
Apply the above rules to <span class="code">name</span>
concatenated with <span class="code">&quot;Check&quot;</span>,
such as loading class
<span class="code">com.puppycrawl.tools.checkstyle.checks.ConstantNameCheck</span> for element
<pre class="body">
&lt;module name=&quot;ConstantName&quot;/&gt;
</pre>
</li>
</ol>
<a name="properties"></a> <h2>Properties</h2>
<p class="body">
Properties of a module control how the module performs its task.
Each module property has a default value, and you are not required to define a property in the
configuration document if the default value is satisfactory.
To assign a non-default value to a module's property,
define a child <span class="code">property</span> element of the <span class="code">module</span>
element in the configuration XML document. Also provide appropriate
<span class="code">name</span> and
<span class="code">value</span> attributes for the <span class="code">property</span> element.
For example, property
<span class="code">max</span> of module <span class="code">MethodLength</span>
specifies the maximum allowable number of lines in a method or constructor, and has default
value <span class="code">150</span>.
Here is a configuration of module <span class="code">MethodLength</span> so that the check reports
methods and constructors with more than <span class="code">60</span> lines:
</p>
<pre class="body">
&lt;module name=&quot;MethodLength&quot;&gt;
&lt;property name=&quot;max&quot; value=&quot;60&quot;/&gt;
&lt;/module&gt;
</pre>
<p class="body">
</p>
<p class="body">
<a href="cmdline.html">Command line</a> properties
and ant <a href="anttask.html">Checkstyle task</a> properties apply
to the root <span class="code">Checker</span>
module. Also, properties are inherited in the
module hierarchy. These features make it easy to define one property value that applies to
many modules. For example, the following configuration fragment specifies that a
<span class="code">tabWidth</span> of <span class="code">4</span> applies to
<span class="code">TreeWalker</span> and its submodules:
</p>
<pre class="body">
&lt;module name=&quot;Checker&quot;&gt;
&lt;module name=&quot;PackageHtml&quot;/&gt;
&lt;module name=&quot;TreeWalker&quot;&gt;
&lt;property name=&quot;tabWidth&quot; value=&quot;4&quot;/&gt;
&lt;module name=&quot;AvoidStarImport&quot;/&gt;
&lt;module name=&quot;ConstantName&quot;/&gt;
...
&lt;/module&gt;
&lt;/module&gt;
</pre>
<p class="body">
The value of a module property can be specified through <em>property expansion</em> with the
<span class="code">${<em>property_name</em>}</span> notation,
where <span class="code"><em>property_name</em></span> is a <a href="cmdline.html">command line</a>
property or an ant <a href="anttask.html">Checkstyle task</a> property.
For example, the following configuration document element gives property
<span class="code">headerFile</span> the value
of command line property <span class="code">checkstyle.header.file</span>:
</p>
<pre class="body">
&lt;property name=&quot;headerFile&quot; value=&quot;${checkstyle.header.file}&quot;/&gt;
</pre>
<p class="body">
You can use property expansion to re-specify a module property value
without changing the configuration document.
</p>
<p class="body">
The property element provides an optional <span class="code">default</span> attribute which is used
when a property in the value cannot be resolved. For example this configuration
snippet from a central configuration file checks that methods have javadoc, but
allows inividual projects to override the severity by specifying
their desired value in the command line property
<span class="code">checkstyle.javadoc.severity</span>:
</p>
<pre class="body">
&lt;module name=&quot;JavaDocMethod&quot;&gt;
&lt;property name=&quot;severity&quot; value=&quot;${checkstyle.javadoc.severity}&quot; default=&quot;error&quot;/&gt;
&lt;/module/&gt;
</pre>
<p class="body">
This feature is a great help when setting up a centralized configuration file
(e.g. one file for the whole company) to lower configuration maintenance costs.
Projects that are happy with the default can simply use that configuration file as is,
but individual projects with special needs have the fexibility to adjust a few
settings to fit their needs without having to copy and maintain the whole configuration.
</p>
<a name="checker"></a> <h2>Checker</h2>
<p class="body">
All configurations have root module <span class="code">Checker</span>.
<span class="code">Checker</span> contains
</p>
<ul class="body">
<li><em>FileSetCheck</em> children: modules that check sets of files.</li>
<li><em>Filter</em> children: modules that filter audit events.</li>
<li><em>AuditListener</em> children: modules that report filtered events.</li>
</ul>
<span class="code">Checker</span> also defines properties that are
inherited by all other modules of a configuration.
</p>
<h4 class="body">Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>basedir</td>
<td>base directory name; stripped off in messages about files</td>
<td><a href="property_types.html#string">string</a></td>
<td><span class="default">null</span></td>
</tr>
<tr>
<td>localeCountry</td>
<td>locale country for messages</td>
<td><a href="property_types.html#string">string</a>: either the empty string or an uppercase ISO 3166 2-letter code</td>
<td>default locale country for the Java Virtual Machine</td>
</tr>
<tr>
<td>localeLanguage</td>
<td>locale language for messages</td>
<td><a href="property_types.html#string">string</a>: either the empty string or a lowercase ISO 639 code</td>
<td>default locale language for the Java Virtual Machine</td>
</tr>
</table>
<p class="body">
For example, the following configuration fragment specifies base directory
<span class="code">src/checkstyle</span> and German locale for all modules:
</p>
<pre class="body">
&lt;module name=&quot;Checker&quot;&gt;
&lt;property name=&quot;basedir&quot; value=&quot;src/checkstyle&quot;/&gt;
&lt;property name=&quot;localeCountry&quot; value=&quot;DE&quot;/&gt;
&lt;property name=&quot;localeLanguage&quot; value=&quot;de&quot;/&gt;
&lt;module name=&quot;PackageHtml&quot;/&gt;
&lt;module name=&quot;TreeWalker&quot;&gt;
...
&lt;/module&gt;
&lt;/module&gt;
</pre>
<a name="treewalker"></a> <h2>TreeWalker</h2>
<p class="body">
FileSetCheck <span class="code">TreeWalker</span> checks individual Java source files
and defines properties that are applicable to checking such files.
</p>
<h4 class="body">Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>cacheFile</td>
<td>caches information about files that have checked ok; used to avoid
repeated checks of the same files</td>
<td><a href="property_types.html#string">string</a></td>
<td><span class="default">null</span> (no cache file)</td>
</tr>
<tr>
<td>tabWidth</td>
<td>number of expanded spaces for a tab character (<span class="code">'\t'</span>);
used in messages and Checks that require a tab width, such as
<a href="config_sizes.html#LineLength"><span class="code">LineLength</span></a></td>
<td><a href="property_types.html#integer">integer</a></td>
<td><span class="default">8</span></td>
</tr>
<tr>
<td>fileExtensions</td>
<td>file type extension to identify java files. Setting this property is
typically only required if your java source code is preprocessed before
compilation and the original files do not have the extension
<span class="code">.java</span></td>
<td><a href="property_types.html#stringSet">String Set</a></td>
<td><span class="default">java</span></td>
</tr>
<tr>
<td>charset</td>
<td>name of the file charset</td>
<td><a href="property_types.html#string">String</a></td>
<td>System property &quot;file.encoding&quot;</td>
</tr>
</table>
<p class="body">
For example, the following configuration fragment specifies <span class="code">TreeWalker</span>
cache file <span class="code">target/cachefile</span>, and a <span class="code">tabWidth</span>
of <span class="code">4</span>:
</p>
<pre class="body">
&lt;module name=&quot;Checker&quot;&gt;
&lt;module name=&quot;TreeWalker&quot;&gt;
&lt;property name=&quot;cacheFile&quot; value=&quot;target/cachefile&quot;/&gt;
&lt;property name=&quot;tabWidth&quot; value=&quot;4&quot;/&gt;
...
&lt;/module&gt;
&lt;/module&gt;
</pre>
<p class="body">
To configure a <span class="code">TreeWalker</span> so that it handles files with the <span class="code">UTF-8</span>
charset:
</p>
<pre class="body">
&lt;module name=&quot;Checker&quot;&gt;
&lt;module name=&quot;TreeWalker&quot;&gt;
&lt;property name=&quot;charset&quot; value=&quot;UTF-8&quot;/&gt;
...
&lt;/module&gt;
&lt;/module&gt;
</pre>
<p class="body">
<!--
thanks to Paul King for this example, see
https://sourceforge.net/tracker/?func=detail&aid=865610&group_id=29721&atid=397078
-->
To integrate Checkstyle with BEA Weblogic Workshop 8.1:
</p>
<pre class="body">
&lt;module name=&quot;Checker&quot;&gt;
&lt;module name=&quot;TreeWalker&quot;&gt;
&lt;property name=&quot;fileExtensions&quot; value=&quot;java,ejb,jpf&quot;/&gt;
...
</pre>
<a name="treewalkerchecks"></a> <h2>TreeWalker Checks</h2>
<p class="body">
The <span class="code">TreeWalker</span> module creates a syntax tree for a Java source file
and invokes its submodules, called <em>Checks</em>, during a walk, or traversal, of the nodes
of the tree.
Every node of the syntax tree has a token. A visit to a node during the traversal
triggers all Checks that are configured for its token.
For example, if Check <span class="code">MethodLength</span> has been configured as
a submodule of <span class="code">TreeWalker</span>, then a visit to a node
with a method or a constructor definition
token triggers <span class="code">MethodLength</span> to check the number of lines
of the node's code block.
</p>
<p class="body">
Some Checks, such as <span class="code">FileLength</span>
and <span class="code">LineLength</span>, apply directly to the source file and do not involve tokens
of the syntax tree.
Other Checks are associated with configurable sets of tokens that
trigger the Checks.
For example, this element configures Check <span class="code">MethodLength</span>:
</p>
<pre class="body">
&lt;module name=&quot;MethodLength&quot;/&gt;
</pre>
<p class="body">
The default token set for <span class="code">MethodLength</span> is
<span class="code">{METHOD_DEF, CTOR_DEF}</span>, method definition and constructor definition
tokens, so <span class="code">TreeWalker</span> invokes
<span class="code">MethodLength</span> whenever it visits a node with a
<span class="code">METHOD_DEF</span> or a <span class="code">CTOR_DEF</span> token.
</p>
<p class="body">
You specify the trigger tokens for a Check with property <span class="code">tokens</span>.
The value of <span class="code">tokens</span> is a list that denotes a subset of the Check's
tokens, as in the following element that configures Check
<span class="code">MethodLength</span> to check the number of lines of methods only:
</p>
<pre class="body">
&lt;module name=&quot;MethodLength&quot;&gt;
&lt;property name=&quot;tokens&quot; value=&quot;METHOD_DEF&quot;/&gt;
&lt;/module&gt;
</pre>
<p class="body">
To apply particular properties to different subsets of tokens for a Check, repeat the Check.
For example, to check that the length of each method is at most 150 lines (the default value
of <span class="code">MethodLength</span> property <span class="code">max</span>) and the
length of each constructor is at most 60 lines, include the following in the
<span class="code">TreeWalker</span> configuration:
</p>
<pre class="body">
&lt;module name=&quot;MethodLength&quot;&gt;
&lt;property name=&quot;tokens&quot; value=&quot;METHOD_DEF&quot;/&gt;
&lt;/module&gt;
&lt;module name=&quot;MethodLength&quot;&gt;
&lt;property name=&quot;tokens&quot; value=&quot;CTOR_DEF&quot;/&gt;
&lt;property name=&quot;max&quot; value=&quot;60&quot;/&gt;
&lt;/module&gt;
</pre>
<p class="body">
Configurations of the Checks are specified in the following pages:
</p>
<ul class="body">
<li>
<a href="config_javadoc.html">Checks For Javadoc Comments</a>
</li>
<li>
<a href="config_naming.html">Checks For Naming Conventions</a>
</li>
<li>
<a href="config_header.html">Checks For Headers</a>
</li>
<li>
<a href="config_import.html">Checks For Imports</a>
</li>
<li>
<a href="config_sizes.html">Checks For Size Violations</a>
</li>
<li>
<a href="config_whitespace.html">Checks For Whitespace</a>
</li>
<li>
<a href="config_modifiers.html">Checks For Modifiers</a>
</li>
<li>
<a href="config_blocks.html">Checks For Blocks</a>
</li>
<li>
<a href="config_coding.html">Checks For Coding Problems</a>
</li>
<li>
<a href="config_design.html">Checks For Design Problems</a>
</li>
<li>
<a href="config_duplicates.html">Checks For Finding Duplicate Code</a>
</li>
<li>
<a href="config_metrics.html">Checks For Metrics</a>
</li>
<li>
<a href="config_misc.html">Miscellaneous Checks</a>
</li>
<li>
<a href="optional.html">Optional Checks</a>
</li>
</ul>
<a name="severity"></a>
<h2>Severity</h2>
<p class="body">
Each check has a <a href="property_types.html#severity">severity</a> property
that a Checkstyle audit assigns to all violations of the check. The default severity level of
a check is <span class="default">error</span>.
</p>
<p class="body">
You can use the severity property to control the output of the plain formatter for the <a href="cmdline.html">command
line tool</a> and the <a href="anttask.html">ANT task</a>. The plain formatter does not report violations with severity level
<span class="default">ignore</span>, and notes violations with severity level
<span class="default">warning</span>. For example, according to the following configuration fragment,
the plain formatter outputs warnings for translation violations:
</p>
<pre class="body">
&lt;module name=&quot;Translation&quot;&gt;
&lt;property name=&quot;severity&quot; value=&quot;warning&quot;/&gt;
&lt;/module&gt;
</pre>
<p class="body">
The XML formatter reports the severity level
of every violation as an attribute of the violation's <span class="default">error</span>
element.
</p>
<a name="filters"></a>
<h2>Filters</h2>
<p class="body">
A Checker module has a set of Filter submodules to filter audit events, including the error messages fired by Checks.
A Filter can accept or reject an audit event. If all Filters accept
an audit event, then the Checker reports the event.
If any Filter rejects an event, then the Checker does not report the event.</p>
<p class="body">
Filter <span class="code">SeverityMatchFilter</span> decides audit events according to the
<a href="#severity">severity level</a> of the event.
</p>
<h4 class="body">SeverityMatchFilter Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>severity</td>
<td>the severity level of this filter</td>
<td><a href="property_types.html#severity">severity</a></td>
<td><span class="default">error</span></td>
</tr>
<tr>
<td>acceptOnMatch</td>
<td>If acceptOnMatch is <span class="code">true</span>, then the filter accepts an audit event if and only if there is
a match between the event's severity level and property severity. If acceptOnMatch is <span class="code">false</span>,
then the filter accepts an audit event if and only if there is not
a match between the event's severity level and property severity.
</td>
<td><a href="property_types.html#boolean">boolean</a></td>
<td><span class="default">true</span></td>
</tr>
</table>
<p class="body">
For example, the following configuration fragment directs the Checker to not report audit events with severity level
<span class="code">info</span>:
</p>
<pre class="body">
&lt;module name=&quot;SeverityMatchFilter&quot;&gt;
&lt;property name=&quot;severity&quot; value=&quot;info&quot;/&gt;
&lt;property name=&quot;acceptOnMatch&quot; value=&quot;false&quot;/&gt;
&lt;/module&gt;
</pre>
<p class="body">
Filter <span class="code">SuppressionFilter</span> rejects audit events for Check errors according to a
<a href="#suppressionsxml"><em>suppressions XML document</em></a> in a file. If there is no configured suppressions file, the
Filter accepts all audit events.
</p>
<h4 class="body">SuppressionFilter Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>file</td>
<td>the name of the <em>suppressions XML document</em> file</td>
<td><a href="property_types.html#string">string</a></td>
<td><span class="default">none</span></td>
</tr>
</table>
<p class="body">
For example, the following configuration fragment directs the Checker to use a <span class="code">SuppressionFilter</span>
with suppressions file <span class="code">docs/suppressions.xml</span>:
</p>
<pre class="body">
&lt;module name=&quot;SuppressionFilter&quot;&gt;
&lt;property name=&quot;file&quot; value=&quot;docs/suppressions.xml&quot;/&gt;
&lt;/module&gt;
</pre>
<p class="body">
A <a href="#suppressionsxml"><em>suppressions XML document</em></a> contains a set of <span class="code">suppress</span> elements,
where each <span class="code">suppress</span> element
has a <span class="code">files</span> attribute, a <span class="code">checks</span> attribute,
an optional <span class="code">lines</span> attribute, and an optional
<span class="code">columns</span> attribute.
Attributes <span class="code">files</span> and <span class="code">checks</span> are
<a href="property_types.html#regexp">regular expressions</a>.
Attributes <span class="code">lines</span> and <span class="code">columns</span> are
comma-separated values, where each value is an <a href="property_types.html#integer">integer</a> or
a range of integers denoted by integer-integer.
</p>
<p class="body">
An audit event for a Check error matches a <span class="code">suppress</span> element if
the file name for the event matches the <span class="code">files</span> attribute of the element,
the name of the Check matches the <span class="code">checks</span> attribute, and
the line of the event matches the <span class="code">lines</span> attribute (provided the attribute exists) or
the column of the event matches the <span class="code">columns</span> attribute (provided the attribute exists).
When a <span class="code">SuppressionFilter</span> decides an audit event for a Check error, it rejects
the event if the event matches any one of the configured <span class="code">suppress</span> elements. In all other
cases, the Filter accepts the event.
</p>
<p class="body">
For example, the following suppressions XML document directs a <span class="code">SuppressionFilter</span>
to reject <span class="code">JavadocStyleCheck</span> errors for lines 82 and 108 to 122 of file
<span class="code">AbstractComplexityCheck.java</span>, and
<span class="code">MagicNumberCheck</span> errors for line 221 of file
<span class="code">JavadocStyleCheck.java</span>:
</p>
<pre class="body">
&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;!DOCTYPE suppressions PUBLIC
&quot;-//Puppy Crawl//DTD Suppressions 1.0//EN&quot;
&quot;http://www.puppycrawl.com/dtds/suppressions_1_0.dtd&quot;&gt;
&lt;suppressions&gt;
&lt;suppress checks=&quot;JavadocStyleCheck&quot;
files=&quot;AbstractComplexityCheck.java&quot;
lines=&quot;82,108-122&quot;/&gt;
&lt;suppress checks=&quot;MagicNumberCheck&quot;
files=&quot;JavadocStyleCheck.java&quot;
lines=&quot;221&quot;/&gt;
&lt;/suppressions&gt;
</pre>
<p class="body">
Filter <span class="code">SuppressionCommentFilter</span> uses
pairs of comments to suppress audit events.
</p>
<p class="body">
Rationale: Sometimes there are legitimate reasons for violating
a check. When this is a matter of the code in question and not
personal preference, the best place to override the policy is in
the code itself. Semi-structured comments can be associated
with the check. This is sometimes superior to a separate
suppressions file, which must be kept up-to-date as the source
file is edited.
</p>
<p class="body">
Usage: This filter only works in conjunction with a
<span class="code">FileContentsHolder</span>, since that check makes the suppression
comments in the .java files available <i>sub rosa</i>. A configuration
that includes this filter must configure <span class="code">FileContentsHolder</span>
as a child module of <span class="code">TreeWalker</span>.
</p>
<h4 class="body">SuppressionCommentFilter Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>offCommentFormat</td>
<td>comment pattern to trigger filter to begin suppression</td>
<td><a href="property_types.html#regexp">regular expression</a></td>
<td><span class="default">CHECKSTYLE\:OFF</span></td>
</tr>
<tr>
<td>onCommentFormat</td>
<td>comment pattern to trigger filter to end suppression</td>
<td><a href="property_types.html#regexp">regular expression</a></td>
<td><span class="default">CHECKSTYLE\:ON</span></td>
</tr>
<tr>
<td>checkFormat</td>
<td>check pattern to suppress</td>
<td><a href="property_types.html#regexp">regular expression</a></td>
<td><span class="default">.*</span> (all checks)</td>
</tr>
<tr>
<td>messageFormat</td>
<td>message pattern to suppress</td>
<td><a href="property_types.html#regexp">regular expression</a></td>
<td>none</td>
</tr>
<tr>
<td>checkCPP</td>
<td>whether to check C++ style comments (<code>//</code>)</td>
<td><a href="property_types.html#boolean">boolean</a></td>
<td><span class="default">true</span></td>
</tr>
<tr>
<td>checkC</td>
<td>whether to check C style comments (<code>/* ... */</code>)</td>
<td><a href="property_types.html#boolean">boolean</a></td>
<td><span class="default">true</span></td>
</tr>
</table>
<h4 class="body">Restrictions</h4>
<p class="body">
offCommentFormat and onCommentFormat must have equal
<a href="http://jakarta.apache.org/regexp/apidocs/org/apache/regexp/RE.html#getParenCount()">paren counts</a>.
</p>
<h4 class="body">Examples</h4>
<p class="body">
To configure the check that makes comments available to the filter:
</p>
<pre class="body">
&lt;module name=&quot;TreeWalker&quot;&gt;
...
&lt;module name=&quot;FileContentsHolder&quot;/&gt;
...
&lt;/module&gt;
</pre>
<p class="body">
To configure a filter to suppress audit events between a
comment containing <code>CHECKSTYLE:OFF</code> and a
comment containing <code>CHECKSTYLE:ON</code>:
</p>
<pre class="body">
&lt;module name=&quot;SuppressionCommentFilter&quot;/&gt;
</pre>
<p class="body">
To configure a filter to suppress audit events between a
comment containing line <code>BEGIN GENERATED CODE</code> and a
comment containing line <code>END GENERATED CODE</code>:
</p>
<pre class="body">
&lt;module name=&quot;SuppressionCommentFilter&quot;&gt;
&lt;property name=&quot;offCommentFormat&quot; value=&quot;BEGIN GENERATED CODE&quot;/&gt;
&lt;property name=&quot;onCommentFormat&quot; value=&quot;END GENERATED CODE&quot;/&gt;
&lt;/module>
</pre>
<p class="body">
To configure a filter so that <code>// stop constant check</code> and
<code>// resume constant check</code>
marks legitimate constant names:
</p>
<pre class="body">
&lt;module name=&quot;SuppressionCommentFilter&quot;&gt;
&lt;property name=&quot;offCommentFormat&quot; value=&quot;stop constant check&quot;/&gt;
&lt;property name=&quot;onCommentFormat&quot; value=&quot;resume constant check&quot;/&gt;
&lt;property name=&quot;checkFormat&quot; value=&quot;ConstantNameCheck&quot;/&gt;
&lt;/module>
</pre>
<p class="body">
To configure a filter so that <code>UNUSED OFF: <i>var</i></code>
and <code>UNUSED ON: <i>var</i></code>
marks a variable or parameter known not to be used by the code
by matching the variable name in the message:
</p>
<pre class="body">
&lt;module name=&quot;SuppressionCommentFilter&quot;&gt;
&lt;property name=&quot;offCommentFormat&quot; value=&quot;UNUSED OFF\: (\w+)&quot;/&gt;
&lt;property name=&quot;onCommentFormat&quot; value=&quot;UNUSED ON\: (\w+)&quot;/&gt;
&lt;property name=&quot;checkFormat&quot; value=&quot;Unused&quot;/&gt;
&lt;property name=&quot;messageFormat&quot; value=&quot;^Unused \w+ '$1'.$&quot;/&gt;
&lt;/module&gt;
</pre>
<p class="body">
To configure a filter so that <code>CSOFF: <i>regexp</i></code>
and <code>CSN: <i>regexp</i></code>
mark a matching check:
</p>
<pre class="body">
&lt;module name=&quot;SuppressionCommentFilter&quot;&gt;
&lt;property name=&quot;offCommentFormat&quot; value=&quot;CSOFF\: ([\w\|]+)&quot;/&gt;
&lt;property name=&quot;onCommentFormat&quot; value=&quot;CSON\: ([\w\|]+)&quot;/&gt;
&lt;property name=&quot;checkFormat&quot; value=&quot;$1&quot;/&gt;
&lt;/module&gt;
</pre>
<a name="auditlisteners"></a>
<h2>AuditListeners</h2>
<p class="body">
In addition to an audit reporter for text or XML output, a Checker can have
<a href="writinglisteners.html">custom AuditListeners</a>
that handle audit events. In order to use a custom listener, add a Checker</span>
submodule for the listener and its properties.
For example, to configure a <span class="code">Checker</span>
so that it uses custom listener <a href="writinglisteners.html#writing">VerboseListener</a> to print audit messages
to a file named &quot;audit.txt&quot;, include the following module in the
configuration file:
</p>
<pre class="body">
&lt;module name=&quot;com.mycompany.listeners.VerboseListener&quot;&gt;
&lt;property name=&quot;file&quot; value=&quot;audit.txt&quot;/&gt;
&lt;/module&gt;
</pre>
</p>
<a name="packagenames"></a>
<h2>Packages</h2>
<p class="body">
Checkstyle loads a module class according to the <span class="code">name</span>
of a <span class="code">module</span> element, and automatically appends pre-specified
package prefixes to that <span class="code">name</span> in its search for a loadable class.
By default, Checkstyle applies packages <span class="code">
com.puppycrawl.tools.checkstyle</span>, <span class="code">
com.puppycrawl.tools.checkstyle.filters</span>, and <span class="code">
com.puppycrawl.tools.checkstyle.checks</span> as well as any sub-packages of
<span class="code">com.puppycrawl.tools.checkstyle.checks</span> that are
distributed with Checkstyle. To specify other packages to apply,
create a <em>package names XML document</em> in a file, and provide that file as a
<a href="cmdline.html">command line</a> option or as a
attribute of an <a href="anttask.html">ant Checkstyle task</a>.
This is useful for integrating other modules in your configuration.
</p>
<p class="body">
A <em>package names XML document</em> specifies a list of package names. Here is a
sample package names XML document for packages <span class="code">
com.puppycrawl.tools.checkstyle</span> and <span class="code">
com.puppycrawl.tools.checkstyle.checks</span>:
</p>
<pre class="body">
&lt;checkstyle-packages&gt;
&lt;package name=&quot;com.puppycrawl.tools.checkstyle&quot;&gt;
&lt;package name=&quot;checks&quot;/&gt;
&lt;/package&gt;
&lt;/checkstyle-packages&gt;
</pre>
<p class="body">
Notice that the packages are specified recursively - a child
<span class="code">package</span> element is
a subpackage of its parent <span class="code">package</span> element.
</p>
<p class="body">
For example, to incorporate modules from package <span class="code">com.mycompany.checks</span>
with Checkstyle modules, create the XML file below and specify that file as a
<a href="cmdline.html">command line</a> option or as a
attribute of an <a href="anttask.html">ant Checkstyle task</a>.:
</p>
<pre class="body">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;!DOCTYPE checkstyle-packages PUBLIC
&quot;-//Puppy Crawl//DTD Package Names 1.0//EN&quot;
&quot;http://www.puppycrawl.com/dtds/packages_1_0.dtd&quot;&gt;
&lt;checkstyle-packages&gt;
&lt;package name=&quot;com.mycompany.checks&quot;&gt;
&lt;package name=&quot;com.puppycrawl.tools.checkstyle&quot;&gt;
&lt;package name=&quot;checks&quot;&gt;
&lt;package name=&quot;blocks&quot;/&gt;
&lt;package name=&quot;coding&quot;/&gt;
&lt;package name=&quot;design&quot;/&gt;
&lt;package name=&quot;imports&quot;/&gt;
&lt;package name=&quot;indentation&quot;/&gt;
&lt;package name=&quot;j2ee&quot;/&gt;
&lt;package name=&quot;javadoc&quot;/&gt;
&lt;package name=&quot;metrics&quot;/&gt;
&lt;package name=&quot;naming&quot;/&gt;
&lt;package name=&quot;sizes&quot;/&gt;
&lt;package name=&quot;whitespace&quot;/&gt;
&lt;/package&gt;
&lt;package name="filters"/&gt;
&lt;/package&gt;
&lt;/checkstyle-packages&gt;
</pre>
<p class="body">
Now you can configure a module of package <span class="code">com.mycompany.checks</span>,
say <span class="code">com.mycompany.checks.MethodLimitCheck</span>, with a shortened
<span class="code">module</span> element in the configuration document:
</p>
<pre class="body">
&lt;module name=&quot;MethodLimit&quot;/&gt;
</pre>
<div class="tip">
<h4 class="tip">Important</h4>
If you provide a package names XML document for your own modules and still need to use
Checkstyle modules, you must include <span class="code">package</span> elements for
Checkstyle's packages.
</div>
<a name="xml"></a>
<h2>XML Details</h2>
<h4>Configuration XML Document</h4>
<p class="body">
The following DTD for a configuration XML document specifies the hierarchy of modules
and their properties:
</p>
<pre class="body">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;!ELEMENT module (module|property)*&gt;
&lt;!ATTLIST module name NMTOKEN #REQUIRED&gt;
&lt;!ELEMENT property EMPTY&gt;
&lt;!ATTLIST property
name NMTOKEN #REQUIRED
value CDATA #REQUIRED
&gt;
</pre>
<p class="body">
Checkstyle validates a configuration XML document when it loads the document.
To validate against the above configuration DTD,
include the following document type declaration in
your configuration XML document:
</p>
<pre class="body">
&lt;!DOCTYPE module PUBLIC
&quot;-//Puppy Crawl//DTD Check Configuration 1.2//EN&quot;
&quot;http://www.puppycrawl.com/dtds/configuration_1_2.dtd&quot;&gt;
</pre>
<p class="body">
Checkstyle also strictly enforces the encoding attribute of an XML declaration.
If Checkstyle rejects your configuration document's encoding,
correct the value of the encoding attribute, or remove the encoding attribute entirely.
</p>
<p class="body">
For a complete example of a configuration XML document, examine file <span class="code">docs/sun_checks.xml</span>
that checks the Sun coding conventions.
</p>
<h4>Package Names XML Document</h4>
<p class="body">
This is a DTD for a package names XML document:
</p>
<pre class="body">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;!ELEMENT checkstyle-packages (package)*&gt;
&lt;!ELEMENT package (package)*&gt;
&lt;!ATTLIST package name NMTOKEN #REQUIRED&gt;
</pre>
<p class="body">
Checkstyle also validates a package names XML document when it loads the document.
To validate against the above package names DTD,
include the following document type declaration in
your package names XML document:
</p>
<pre class="body">
&lt;!DOCTYPE checkstyle-packages PUBLIC
&quot;-//Puppy Crawl//DTD Package Names 1.0//EN&quot;
&quot;http://www.puppycrawl.com/dtds/packages_1_0.dtd&quot;&gt;
</pre>
<a name="suppressionsxml"></a>
<h4>Suppressions XML Document</h4>
<p class="body">
This is a DTD for a suppressions XML document:
</p>
<pre class="body">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;!ELEMENT suppressions (suppress*)&gt;
&lt;!ELEMENT suppress EMPTY&gt;
&lt;!ATTLIST suppress files CDATA #REQUIRED
checks CDATA #REQUIRED
lines CDATA #IMPLIED
columns CDATA #IMPLIED&gt;
</pre>
</td>
</tr>
</table>
<hr />
<div><a href="index.html">Back to the Checkstyle Home Page</a></div>
<p class="copyright">
Copyright © 2002-2004 Oliver Burn. All rights Reserved.
</p>
</body>
</html>

View File

@ -1,437 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Checks for blocks</title>
<link rel="stylesheet" type="text/css" href="mystyle.css"/>
</head>
<body>
<!-- The header -->
<table border="0" width="100%" summary="header layout">
<tr>
<td><h1>Checks for blocks</h1></td>
<td align="right"><img src="logo.png" alt="Checkstyle Logo"/></td>
</tr>
</table>
<!-- content -->
<table border="0" width="100%" cellpadding="5" summary="body layout">
<tr>
<!--Left menu-->
<td class="menu" valign="top">
<ul>
<li>
<a href="#EmptyBlock">EmptyBlock</a>
</li>
<li>
<a href="#LeftCurly">LeftCurly</a>
</li>
<li>
<a href="#NeedBraces">NeedBraces</a>
</li>
<li>
<a href="#RightCurly">RightCurly</a>
</li>
<li>
<a href="#AvoidNestedBlocks">AvoidNestedBlocks</a>
</li>
</ul>
</td>
<!--Content-->
<td class="content" valign="top" align="left"><a name="EmptyBlock"></a> <h2>EmptyBlock</h2>
<h4>Description</h4>
<p class="body">
Checks for empty blocks.
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>option</td>
<td>policy on block contents</td>
<td><a href="property_types.html#block">block policy</a></td>
<td><span class="default">stmt</span></td>
</tr>
<tr>
<td>tokens</td>
<td>blocks to check</td>
<td>subset of tokens <a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_CATCH">LITERAL_CATCH</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_DO">LITERAL_DO</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_ELSE">LITERAL_ELSE</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_FINALLY">LITERAL_FINALLY</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_IF">LITERAL_IF</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_FOR">LITERAL_FOR</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_TRY">LITERAL_TRY</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_WHILE">LITERAL_WHILE</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#INSTANCE_INIT">INSTANCE_INIT</a>
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#STATIC_INIT">STATIC_INIT</a></td>
<td>all tokens</td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;EmptyBlock&quot;/&gt;
</pre>
<p class="body">
To configure the check for the <span class="code">text</span> policy and only <span class="code">
catch</span> blocks:
</p>
<pre class="body">
&lt;module name=&quot;EmptyBlock&quot;&gt;
&lt;property name=&quot;option&quot; value=&quot;text&quot;/&gt;
&lt;property name=&quot;tokens&quot; value=&quot;LITERAL_CATCH&quot;/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.blocks
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<a name="LeftCurly"></a> <h2>LeftCurly</h2> <h4>Description</h4>
<p class="body">
Checks for the placement of left curly braces (<span class="code">'{'</span>) for code blocks.
The policy to verify is specified using property <span class="code">option</span>.
Policies <span class="code">eol</span> and <span class="code">
nlow</span> take into account property <span class="code">maxLineLength</span>.
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>option</td>
<td>policy on placement of a left curly brace (<span class="code">'{'</span>)</td>
<td><a href="property_types.html#lcurly">left curly brace policy</a></td>
<td><span class="default">eol</span></td>
</tr>
<tr>
<td>maxLineLength</td>
<td>maximum number of characters in a line</td>
<td><a href="property_types.html#integer">integer</a></td>
<td><span class="default">80</span></td>
</tr>
<tr>
<td>tokens</td>
<td>blocks to check</td>
<td>subset of tokens <a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CLASS_DEF">CLASS_DEF</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CTOR_DEF">CTOR_DEF</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#INTERFACE_DEF">INTERFACE_DEF</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_CATCH">LITERAL_CATCH</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_DO">LITERAL_DO</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_ELSE">LITERAL_ELSE</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_FINALLY">LITERAL_FINALLY</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_FOR">LITERAL_FOR</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_IF">LITERAL_IF</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_SWITCH">LITERAL_SWITCH</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_SYNCHRONIZED">LITERAL_SYNCHRONIZED</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_TRY">LITERAL_TRY</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_WHILE">LITERAL_WHILE</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#METHOD_DEF">METHOD_DEF</a></td>
<td>all tokens</td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;LeftCurly&quot;/&gt;
</pre>
<p class="body">
To configure the check to apply the <span class="code">nl</span> policy to type blocks:
</p>
<pre class="body">
&lt;module name=&quot;LeftCurly&quot;&gt;
&lt;property name=&quot;option&quot; value=&quot;nl&quot;/&gt;
&lt;property name=&quot;tokens&quot; value=&quot;CLASS_DEF,INTERFACE_DEF&quot;/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.blocks
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<a name="NeedBraces"></a> <h2>NeedBraces</h2> <h4>Description</h4>
<p class="body">
Checks for braces around code blocks.
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>tokens</td>
<td>blocks to check</td>
<td>subset of tokens <a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_DO">LITERAL_DO</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_ELSE">LITERAL_ELSE</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_IF">LITERAL_IF</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_FOR">LITERAL_FOR</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_WHILE">LITERAL_WHILE</a></td>
<td>all tokens</td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;NeedBraces&quot;/&gt;
</pre>
<p class="body">
To configure the check for <span class="code">if</span> and <span class="code">
else</span> blocks:
</p>
<pre class="body">
&lt;module name=&quot;NeedBraces&quot;&gt;
&lt;property name=&quot;tokens&quot; value=&quot;LITERAL_IF, LITERAL_ELSE&quot;/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.blocks
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<a name="RightCurly"></a> <h2>RightCurly</h2> <h4>Description</h4>
<p class="body">
Checks the placement of right curly braces (<span class="code">'}'</span>) for <span class="code">
else</span>, <span class="code">try</span>, and <span class="code">catch</span>
tokens. The policy to verify is specified using property <span class="code">
option</span>.
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>option</td>
<td>policy on placement of a right curly brace (<span class="code">'}'</span>)</td>
<td><a href="property_types.html#rcurly">right curly brace policy</a></td>
<td><span class="default">same</span></td>
</tr>
<tr>
<td>tokens</td>
<td>blocks to check</td>
<td>subset of tokens <a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_CATCH">LITERAL_CATCH</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_ELSE">LITERAL_ELSE</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_TRY">LITERAL_TRY</a></td>
<td><a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_CATCH">LITERAL_CATCH</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_ELSE">LITERAL_ELSE</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_TRY">LITERAL_TRY</a></td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;RightCurly&quot;/&gt;
</pre>
<p class="body">
To configure the check with policy <span class="code">alone</span> for <span class="code">
else</span> tokens:
</p>
<pre class="body">
&lt;module name=&quot;RightCurly&quot;&gt;
&lt;property name=&quot;option&quot; value=&quot;alone&quot;/&gt;
&lt;property name=&quot;tokens&quot; value=&quot;LITERAL_ELSE&quot;/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.blocks
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<!-- --> <a name="AvoidNestedBlocks"></a> <h2>AvoidNestedBlocks</h2> <h4>Description</h4>
<p class="body">
Finds nested blocks, i.e. blocks that are used freely in the code.
<p class="body">
Rationale: Nested blocks are often leftovers from the debugging process,
they confuse the reader.
</p>
<p>
For example this Check finds the obsolete braces in
</p>
<pre class="body">
public void guessTheOutput()
{
int whichIsWich = 0;
{
int whichIsWhich = 2;
}
System.out.println("value = " + whichIsWhich);
}
</pre>
<p class="body">
and debugging / refactoring leftovers such as
</p>
<pre class="body">
// if (conditionThatIsNotUsedAnyLonger)
{
System.out.println("unconditional");
}
</pre>
<p class="body">
A case in a switch statement does not implicitly form a block.
Thus to be able to introduce local variables that have case scope
it is necessary to open a nested block. This is supported, set
the allowInSwitchCase property to true and include all statements
of the case in the block.
</p>
<pre class="body">
switch (a)
{
case 0:
// Never OK, break outside block
{
x = 1;
}
break;
case 1:
// Never OK, statement outside block
System.out.println("Hello");
{
x = 2;
break;
}
case 1:
// OK if allowInSwitchCase is true
{
System.out.println("Hello");
x = 2;
break;
}
}
</pre>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>allowInSwitchCase</td>
<td>Allow nested blocks in case statements</td>
<td><a href="property_types.html#boolean">boolean</a></td>
<td><span class="default">false</span></td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;AvoidNestedBlocks&quot;/&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.blocks
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
</td>
</tr>
</table>
<hr />
<div><a href="index.html">Back to the Checkstyle Home Page</a></div>
<p class="copyright">
Copyright &copy; 2002-2004 Oliver Burn. All rights Reserved.
</p>
</body>
</html>

File diff suppressed because it is too large Load Diff

View File

@ -1,415 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class Design Checks</title>
<link rel="stylesheet" type="text/css" href="mystyle.css"/>
</head>
<body>
<!-- The header -->
<table border="0" width="100%" summary="header layout">
<tr>
<td><h1>Class Design Checks</h1></td>
<td align="right"><img src="logo.png" alt="Checkstyle Logo"/></td>
</tr>
</table>
<!-- content -->
<table border="0" width="100%" cellpadding="5" summary="body layout">
<tr>
<!--Left menu-->
<td class="menu" valign="top">
<ul>
<li>
<a href="#DesignForExtension">DesignForExtension</a>
</li>
<li>
<a href="#FinalClass">FinalClass</a>
</li>
<li>
<a href="#HideUtilityClassConstructor">HideUtilityClassConstructor</a>
</li>
<li>
<a href="#InterfaceIsType">InterfaceIsType</a>
</li>
<li>
<a href="#MutableException">MutableException</a>
</li>
<li>
<a href="#ThrowsCount">ThrowsCount</a>
</li>
<li>
<a href="#VisibilityModifier">VisibilityModifier</a>
</li>
</ul>
</td>
<!--Content-->
<td class="content" valign="top" align="left">
<a name="VisibilityModifier"></a><h2>VisibilityModifier</h2>
<p class="body">
Checks visibility of class members. Only static final members
may be public; other class members must be private unless
property <span class="code">protectedAllowed</span> or <span
class="code">packageAllowed</span> is set.
</p>
<p class="body">
Public members are not flagged if the name matches the public
member regular expression (contains <span
class="code">"^serialVersionUID$"</span> by default). Note:
Checkstyle 2 used to include <span
class="code">"^f[A-Z][a-zA-Z0-9]*$"</span> in the default
pattern to allow CMP for EJB 1.1 with the default settings.
With EJB 2.0 it is not longer necessary to have public access
for persistent fields, hence the default has been changed.
</p>
<p class="body">
Rationale: Enforce encapsulation.
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>packageAllowed</td>
<td>whether package visible members are allowed</td>
<td><a href="property_types.html#boolean">boolean</a></td>
<td><span class="default">false</span></td>
</tr>
<tr>
<td>protectedAllowed</td>
<td>whether protected members are allowed</td>
<td><a href="property_types.html#boolean">boolean</a></td>
<td><span class="default">false</span></td>
</tr>
<tr>
<td>publicMemberPattern</td>
<td>pattern for public members that should be ignored</td>
<td><a href="property_types.html#regexp">regular expression</a></td>
<td><span class="default">^serialVersionUID$</span></td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;VisibilityModifier&quot;/&gt;
</pre>
<p class="body">
To configure the check so that it allows package visible members:
</p>
<pre class="body">
&lt;module name=&quot;VisibilityModifier&quot;&gt;
&lt;property name=&quot;packageAllowed&quot; value=&quot;true&quot;/&gt;
&lt;/module&gt;
</pre>
<p class="body">
To configure the check so that it allows no public members:
</p>
<pre class="body">
&lt;module name=&quot;VisibilityModifier&quot;&gt;
&lt;property name=&quot;publicMemberPattern&quot; value=&quot;^$&quot;/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.design
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<!-- --> <a name="FinalClass"></a><h2>FinalClass</h2>
<p class="body">
Checks that a class which has only private constructors is declared as final.
</p>
<h4>Example</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;FinalClass&quot;/&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.design
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<!-- --> <a name="InterfaceIsType"></a> <h2>InterfaceIsType</h2> <h4>Description</h4>
<p class="body">
Implements Bloch, Effective Java, Item 17 -
Use Interfaces only to define types.
</p>
<p class="body">
According to Bloch, an interface should describe a <em>type</em>.
It is therefore inappropriate to define an interface that does not
contain any methods but only constants. The Standard class
<a href="http://java.sun.com/j2se/1.4.1/docs/api/javax/swing/SwingConstants.html">javax.swing.SwingConstants</a>
is an example of a class that would be flagged by this check.
</p>
<p class="body">
The check can be configured to also disallow marker interfaces like
<code>java.io.Serializable</code>, that do not contain methods or
constants at all.
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>allowMarkerInterfaces</td>
<td>Controls whether marker interfaces like Serializable are allowed.</td>
<td><a href="property_types.html#boolean">Boolean</a></td>
<td><span class="default">true</span></td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;InterfaceIsType&quot;/&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.design
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<!-- --> <a name="HideUtilityClassConstructor"></a> <h2>HideUtilityClassConstructor</h2> <h4>Description</h4>
<p class="body">
Make sure that utility classes (classes that contain only static methods)
do not have a public constructor.
</p>
<p class="body">
Rationale: Instantiating utility classes does not make sense.
Hence the constructors should either be private or (if you
want to allow subclassing) protected. A common mistake is forgetting
to hide the default constructor.
</p>
<p class="body">
If you make the constructor protected you may want to consider
the following constructor implementation technique to disallow
instantiating subclasses:
</p>
<pre class="body">
public class StringUtils // not final to allow subclassing
{
protected StringUtils() {
throw new UnsupportedOperationException(); // prevents calls from subclass
}
public static int count(char c, String s) {
// ...
}
}
</pre>
<h4>Examples</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;HideUtilityClassConstructor&quot;/&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.design
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<!-- --> <a name="DesignForExtension"></a> <h2>DesignForExtension</h2> <h4>Description</h4>
<p class="body">
Checks that classes are designed for extension.
More specifically, it enforces a programming style
where superclasses provide empty "hooks" that can be
implemented by subclasses.
</p>
<p class="body">
The exact rule is that nonprivate, nonstatic methods of classes that
can be subclassed must either be
</p>
<ul class="body">
<li>abstract or</li>
<li>final or</li>
<li>have an empty implementation</li>
</ul>
<p class="body">
Rationale: This API design style protects superclasses against beeing broken by
subclasses. The downside is that subclasses are limited in their flexibility,
in particular they cannot prevent execution of code in the superclass, but that also
means that subclasses cannot corrupt the state of the superclass by forgetting to
call the super method.
</p>
<h4>Properties</h4>
None.
<h4>Examples</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;DesignForExtension&quot;/&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.design
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<!-- --> <a name="MutableException"></a> <h2>MutableException</h2> <h4>Description</h4>
<p class="body">
Ensures that exceptions (defined as any class name conforming
to some regular expression) are immutable. That is, have only
final fields.
</p>
<p class="body">
The current algorithm is very simple it checks that all
members of exception are final. User can still mutates an
exception's instance (e.g. Throwable has
setStackTrace(StackTraceElement[] stackTrace) method which
changes stack trace). But, at least, all information provided
by this exception type is unchangable.
</p>
<p class="body">
Rationale:
Exception instances should represent an error
condition. Having non final fields not only allows the
state to be modified by accident and therefore mask the
original condition but also allows developers to
accidentally forget to initialise state thereby leading
to code catching the exception to draw incorrect
conclusions based on the state.
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>format</td>
<td>pattern for name of exception class.</td>
<td><a href="property_types.html#regexp">regular expression</a></td>
<td><span class="default">^.*Exception$|^.*Error$</span></td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;MutableException&quot;/&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.design
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<!-- --> <a name="ThrowsCount"></a> <h2>ThrowsCount</h2> <h4>Description</h4>
<p class="body">
Restricts throws statements to a specified count (default = 1).
</p>
<p class="body">
Rationale:
Exceptions form part of a methods interface. Declaring
a method to throw too many differently rooted
exceptions makes exception handling onerous and leads
to poor programming practices such as catch
(Exception). This check forces developers to put
exceptions into a heirachy such that in the simplest
case, only one type of exception need be checked for by
a caller but allows any sub-classes to be caught
specifically if necessary.
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>max</td>
<td>maximum allowed number of throws statments</td>
<td><a href="property_types.html#integer">Integer</a></td>
<td><span class="default">1</span></td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check so that it doesn't allow more than two
throws per method:
</p>
<pre class="body">
&lt;module name=&quot;ThrowsCount&quot;&gt;
&lt;property name=&quot;max&quot; value=&quot;2&quot;/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.design
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
</td>
</tr>
</table>
<hr />
<div><a href="index.html">Back to the Checkstyle Home Page</a></div>
<p class="copyright">
Copyright &copy; 2002-2004 Oliver Burn. All rights Reserved.
</p>
</body>
</html>

View File

@ -1,295 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Checks for imports</title>
<link rel="stylesheet" type="text/css" href="mystyle.css"/>
</head>
<body>
<!-- The header -->
<table border="0" width="100%" summary="header layout">
<tr>
<td><h1>Checks for imports</h1></td>
<td align="right"><img src="logo.png" alt="Checkstyle Logo"/></td>
</tr>
</table>
<!-- content -->
<table border="0" width="100%" cellpadding="5" summary="body layout">
<tr>
<!--Left menu-->
<td class="menu" valign="top">
<ul>
<li>
<a href="#AvoidStarImport">AvoidStarImport</a>
</li>
<li>
<a href="#ImportOrder">ImportOrder</a>
</li>
<li>
<a href="#IllegalImport">IllegalImport</a>
</li>
<li>
<a href="#RedundantImport">RedundantImport</a>
</li>
<li>
<a href="#UnusedImports">UnusedImports</a>
</li>
</ul>
</td>
<!--Content-->
<td class="content" valign="top" align="left">
<a name="AvoidStarImport"></a> <h2>AvoidStarImport</h2>
<h4>Description</h4>
<p class="body">
Checks that there are no import statements that use the * notation.
</p>
<p class="body">
Rationale: Importing all classes from a package leads to tight coupling
between packages and might lead to problems when a new version of a library
introduces name clashes.
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>excludes</td>
<td>packages where star imports are allowed. Note that this
property is not recursive, subpackages of excluded packages are not
automatically excluded.</td>
<td><a href="property_types.html#stringSet">list of strings</a></td>
<td><span class="default">empty list</span></td>
</tr>
</table>
<h4>Example</h4>
<p class="body">
An example how to configure the check so that star imports
from java.io and java.net are allowed:
</p>
<pre class="body">
&lt;module name="AvoidStarImport"&gt;
&lt;property name="excludes" value="java.io,java.net"/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.imports
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<a name="IllegalImport"></a> <h2>IllegalImport</h2>
<h4>Description</h4>
<p class="body">
Checks for imports from a set of illegal packages. By default, the check rejects
all <span class="code">sun.*</span> packages since programs that contain direct
calls to the <span class="code">sun.*</span> packages are <a href="http://java.sun.com/products/jdk/faq/faq-sun-packages.html">not
100% Pure Java</a>. To reject other packages, set property <span class="code">
illegalPkgs</span> to a list of the illegal packages.
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>illegalPkgs</td>
<td>packages to reject</td>
<td><a href="property_types.html#stringSet">list of strings</a></td>
<td><span class="default">sun</span></td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;IllegalImport&quot;/&gt;
</pre>
<p class="body">
To configure the check so that it rejects packages <span class="code">java.io.*</span>
and <span class="code">java.sql.*</span>:
</p>
<pre class="body">
&lt;module name=&quot;IllegalImport&quot;&gt;
&lt;property name=&quot;illegalPkgs&quot; value=&quot;java.io, java.sql&quot;/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.imports
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<a name="RedundantImport"></a> <h2>RedundantImport</h2> <h4>Description</h4>
<p class="body">
Checks for redundant import statements. An import statement is considered
redundant if:
</p>
<ul class="body">
<li>
It is a duplicate of another import. This is, when a class is imported more than
once.
</li>
<li>
The class imported is from the <span class="code">java.lang</span> package, e.g.
importing <span class="code">java.lang.String</span>.
</li>
<li>
The class imported is from the same package.
</li>
</ul>
<h4>Example</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;RedundantImport&quot;/&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.imports
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<a name="UnusedImports"></a> <h2>UnusedImports</h2> <h4>Description</h4>
<p class="body">
Checks for unused import statements. Checkstyle uses a simple but very reliable
algorithm to report on unused import statements. An import statement is
considered unused if:
</p>
<ul class="body">
<li>
It is not referenced in the file. The algorithm does not support wild-card
imports like <span class="code">import java.io.*;</span>. Most IDE's provide
very sophisticated checks for imports that handle wild-card imports.
</li>
<li>
It is a duplicate of another import. This is when a class is imported more than
once.
</li>
<li>
The class imported is from the <span class="code">java.lang</span> package. For
example importing <span class="code">java.lang.String</span>.
</li>
<li>
The class imported is from the same package.
</li>
</ul>
<h4>Example</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;UnusedImports&quot;/&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.imports
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<a name="ImportOrder"></a> <h2>ImportOrder</h2> <h4>Description</h4>
<p class="body">Checks the ordering/grouping of imports.
Ensures that groups of imports come in a specific order (e.g.,
java. comes first, javax. comes first, then everything else) and
imports within each group are in lexicographic order.
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>groups</td>
<td>list of imports groups (every group identified by string
it's started)</td>
<td><a href="property_types.html#stringSet">list of strings</a></td>
<td><span class="default">empty list</span></td>
</tr>
<tr>
<td>ordered</td>
<td>whether imports within group should be sorted</td>
<td><a href="property_types.html#Boolean">Boolean</a></td>
<td>true</td>
</tr>
<tr>
<td>separated</td>
<td>whether imports groups should be separated by, at least,
one blank line</td>
<td><a href="property_types.html#Boolean">Boolean</a></td>
<td>false</td>
</tr>
<tr>
<td>caseSensitive</td>
<td>whether strings comprision should be case sensitive or not</td>
<td><a href="property_types.html#Boolean">Boolean</a></td>
<td>true</td>
</tr>
</table>
<h4>Example</h4>
<p class="body">
To configure the check so that it requires &quot;java&quot;
packages first, than &quot;javax&quot; and than all other
imports, imports will be sorted in the groups and groups are
separated by, at least, on blank line:
</p>
<pre class="body">
&lt;module name=&quot;ImportOrder&quot;>
&lt;property name=&quot;groups&quot; value=&quot;java,javax&quot;/>
&lt;property name=&quot;ordered&quot; value=&quot;true&quot;/>
&lt;property name=&quot;separated&quot; value=&quot;true&quot;/>
&lt;/module>
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.imports
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
</td>
</tr>
</table>
<hr />
<div><a href="index.html">Back to the Checkstyle Home Page</a></div>
<p class="copyright">
Copyright &copy; 2002-2004 Oliver Burn. All rights Reserved.
</p>
</body>
</html>

View File

@ -1,511 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Checks for J2EE coding problems</title>
<link rel="stylesheet" type="text/css" href="mystyle.css"/>
</head>
<body>
<!-- The header -->
<table border="0" width="100%" summary="header layout">
<tr>
<td><h1>Checks for J2EE coding problems</h1></td>
<td align="right"><img src="logo.png" alt="Checkstyle Logo"/></td>
</tr>
</table>
<!-- content -->
<table border="0" width="100%" cellpadding="5" summary="body layout">
<tr>
<!--Left menu-->
<td class="menu" valign="top">
<ul>
<li>
<a href="#EntityBean">EntityBean</a>
</li>
<li>
<a href="#FinalStatic">FinalStatic</a>
</li>
<li>
<a href="#LocalHomeInterface">LocalHomeInterface</a>
</li>
<li>
<a href="#LocalInterface">LocalInterface</a>
</li>
<li>
<a href="#MessageBean">MessageBean</a>
</li>
<li>
<a href="#RemoteHomeInterface">RemoteHomeInterface</a>
</li>
<li>
<a href="#RemoteInterface">RemoteInterface</a>
</li>
<li>
<a href="#SessionBean">SessionBean</a>
</li>
<li>
<a href="#ThisParameter">ThisParameter</a>
</li>
<li>
<a href="#ThisReturn">ThisReturn</a>
</li>
</ul>
</td>
<!--Content-->
<td class="content" valign="top" align="left">
<!-- --><a name="EntityBean"></a> <h2>EntityBean</h2> <h4>Description</h4>
<p class="body">
Checks that a direct entity bean, i.e. a class that directly implements
<span class="code">javax.ejb.EntityBean</span>, satisfies these class requirements:
</p>
<ul>
<li class="body">
The class is defined as <span class="code">public</span>.
</li>
<li class="body">
The class cannot be defined as <span class="code">final</span>.
</li>
<li class="body">
It contains a <span class="code">public</span> constructor with no parameters.
</li>
<li class="body">
It must not define the <span class="code">finalize</span> method.
</li>
</ul>
<p class="body">
Checks that methods of a direct entity bean satisfy these requirements:
</p>
<ul>
<li class="body">
All <span class="code">ejbCreate&lt;METHOD&gt;(...)</span> methods are
<span class="code">public</span>, not <span class="code">final</span>, and not
<span class="code">static</span>.
</li>
<li class="body">
The return type of all <span class="code">ejbCreate&lt;METHOD&gt;(...)</span>
methods is not <span class="code">void</span>, because the return type must be
the entity bean's primary key type.
</li>
<li class="body">
All <span class="code">ejbPostCreate&lt;METHOD&gt;(...)</span> methods are
<span class="code">public</span>, not <span class="code">final</span>, and not
<span class="code">static</span>.
</li>
<li class="body">
The return type of all <span class="code">ejbPostCreate&lt;METHOD&gt;(...)</span>
methods is <span class="code">void</span>.
</li>
<li class="body">
For each <span class="code">ejbCreate&lt;METHOD&gt;(...)</span> method there is
a matching <span class="code">ejbPostCreate&lt;METHOD&gt;(...)</span> method.
</li>
</li>
<li class="body">
All <span class="code">ejbHome&lt;METHOD&gt;(...)</span> methods are
<span class="code">public</span>, and not <span class="code">static</span>.
</li>
<li class="body">
The throws clause of all <span class="code">ejbHome&lt;METHOD&gt;(...)</span>
methods does not define the <span class="code">java.rmi.RemoteException</span>.
</li>
</ul>
<p class="body">
When the check is configured to check direct entity beans as having bean-managed
persistence, checks that methods satisfy these additional requirements:
</p>
<ul>
<li class="body">
All <span class="code">ejbFind&lt;METHOD&gt;(...)</span> methods are
<span class="code">public</span>, not <span class="code">final</span>, and not
<span class="code">static</span>.
</li>
<li class="body">
The return type of all <span class="code">ejbFind&lt;METHOD&gt;(...)</span>
methods is not <span class="code">void</span>, because the return type must be
the entity bean's primary key type, or a collection of primary keys.
</li>
<li class="body">
There is a <span class="code">ejbFindByPrimaryKey</span> method with one parameter.
</li>
</ul>
<p class="body">
When the check is configured to check direct entity beans as having container-managed
persistence, checks that methods satisfy these additional requirements:
</p>
<ul>
<li class="body">
The throws clause of all <span class="code">ejbCreate&lt;METHOD&gt;(...)</span>
methods defines the <span class="code">javax.ejb.CreateException</span>.
</li>
<li class="body">
All <span class="code">ejbSelect&lt;METHOD&gt;(...)</span> methods are
<span class="code">public</span> and <span class="code">abstract</span>.
</li>
<li class="body">
The throws clause of all <span class="code">ejbSelect&lt;METHOD&gt;(...)</span>
methods defines the <span class="code">javax.ejb.FinderException</span>.
</li>
</ul>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>persistence</td>
<td>type of persistence management</td>
<td><a href="property_types.html#persistence">persistence policy</a></td>
<td><span class="default">mixed</span></td>
</tr>
</table>
<p class="body">
Reference: Enterprise JavaBeans&trade; Specification,Version 2.0, sections
10.6 and 12.2.
</p>
<h4>Example</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;j2ee.EntityBean&quot;/&gt;
</pre>
<p class="body">
To configure the check to apply the <span class="code">container</span> policy to direct entity beans:
</p>
<pre class="body">
&lt;module name=&quot;j2ee.EntityBean&quot;&gt;
&lt;property name=&quot;persistence&quot; value=&quot;container&quot;/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.j2ee
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<!-- --><a name="FinalStatic"></a> <h2>FinalStatic</h2> <h4>Description</h4>
<p class="body">
Checks that all static fields are declared final.
</p>
<p class="body">
Rational: This check ensures consistent runtime semantics so that EJB containers have
the flexibility to distribute instances across multiple JVMs.
</p>
<p class="body">
Reference: <a href="http://www.javaworld.com/javaworld/jw-08-2000/jw-0825-ejbrestrict.html">Programming restrictions on EJB</a>.
</p>
<h4>Example</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;j2ee.FinalStatic&quot;/&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.j2ee
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<!-- --><a name="LocalHomeInterface"></a> <h2>LocalHomeInterface</h2> <h4>Description</h4>
<p class="body">
Checks that a direct local home interface, i.e. an interface that directly extends
<span class="code">javax.ejb.EJBLocalHome</span>, satisfies these requirements:
</p>
<ul>
<li class="body">
The return type of all <span class="code">create&lt;METHOD&gt;(...)</span>
methods is not <span class="code">void</span>, because the return type must be
the bean's local interface.
</li>
<li class="body">
The throws clause of all <span class="code">create&lt;METHOD&gt;(...)</span>
methods defines the <span class="code">javax.ejb.CreateException</span>.
</li>
<li class="body">The throws clause of all methods does not define the <span class="code">java.rmi.RemoteException</span>.</li>
</ul>
<p class="body">
Reference: Enterprise JavaBeansTM Specification,Version 2.0, sections 6.4 and 9.6.
</p>
<h4>Example</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;j2ee.LocalHomeInterface&quot;/&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.j2ee
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<!-- --><a name="LocalInterface"></a> <h2>LocalInterface</h2> <h4>Description</h4>
<p class="body">
Checks that a direct local interface, i.e. an interface that directly extends
<span class="code">javax.ejb.EJBLocalObject</span>, satisfies these requirements:
</p>
<ul>
<li class="body">The throws clause of all methods does not define the <span class="code">java.rmi.RemoteException</span>.</li>
</ul>
<p class="body">
Reference: Enterprise JavaBeansTM Specification,Version 2.0, section 9.10.
</p>
<h4>Example</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;j2ee.LocalInterface&quot;/&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.j2ee
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<!-- --><a name="MessageBean"></a> <h2>MessageBean</h2> <h4>Description</h4>
<p class="body">
Checks that a direct message bean, i.e. a class that directly implements
<span class="code">javax.ejb.MessageDrivenBean</span> and
<span class="code">javax.jms.MessageListener</span>, satisfies these class requirements:
</p>
<ul>
<li class="body">
The class is defined as <span class="code">public</span>.
</li>
<li class="body">
The class cannot be defined as <span class="code">final</span>.
</li>
<li class="body">
The class cannot be defined as <span class="code">abstract</span>.
</li>
<li class="body">
It contains a <span class="code">public</span> constructor with no parameters.
</li>
<li class="body">
It must not define the <span class="code">finalize</span> method.
</li>
<li class="body">
It defines an <span class="code">ejbCreate()</span> method this is
<span class="code">public</span>, not <span class="code">final</span>,
not <span class="code">static</span>, has no parameters, and has
return type <span class="code">void</span>.
</li>
</ul>
<p class="body">
Reference: Enterprise JavaBeans&trade; Specification,Version 2.0, section 15.7.
</p>
<h4>Example</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;j2ee.MessageBean&quot;/&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.j2ee
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<!-- --><a name="RemoteHomeInterface"></a> <h2>RemoteHomeInterface</h2> <h4>Description</h4>
<p class="body">
Checks that a direct remote home interface, i.e. an interface that directly extends
<span class="code">javax.ejb.EJBHome</span>, satisfies these requirements:
</p>
<ul>
<li class="body">
The return type of all <span class="code">create&lt;METHOD&gt;(...)</span>
methods is not <span class="code">void</span>, because the return type must be
the bean's remote interface.
</li>
<li class="body">
The throws clause of all <span class="code">create&lt;METHOD&gt;(...)</span>
methods defines the <span class="code">javax.ejb.CreateException</span>.
</li>
<li class="body">The throws clause of all methods defines the <span class="code">java.rmi.RemoteException</span>.</li>
</ul>
<p class="body">
Reference: Enterprise JavaBeansTM Specification,Version 2.0, sections 6.3 and 9.5.
</p>
<h4>Example</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;j2ee.RemoteHomeInterface&quot;/&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.j2ee
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<!-- --><a name="RemoteInterface"></a> <h2>RemoteInterface</h2> <h4>Description</h4>
<p class="body">
Checks that a direct remote interface, i.e. an interface that directly extends
<span class="code">javax.ejb.EJBObject</span>, satisfies these requirements:
</p>
<ul>
<li class="body">The throws clause of all methods defines the <span class="code">java.rmi.RemoteException</span>.</li>
</ul>
<p class="body">
Reference: Enterprise JavaBeansTM Specification,Version 2.0, section 9.9.
</p>
<h4>Example</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;j2ee.RemoteInterface&quot;/&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.j2ee
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<!-- --><a name="SessionBean"></a> <h2>SessionBean</h2> <h4>Description</h4>
<p class="body">
Checks that a direct session bean, i.e. a class that directly implements
<span class="code">javax.ejb.SessionBean</span>, satisfies these class requirements:
</p>
<ul>
<li class="body">
The class is defined as <span class="code">public</span>.
</li>
<li class="body">
The class cannot be defined as <span class="code">final</span>.
</li>
<li class="body">
The class cannot be defined as <span class="code">abstract</span>.
</li>
<li class="body">
It contains a <span class="code">public</span> constructor with no parameters.
</li>
<li class="body">
It must not define the <span class="code">finalize</span> method.
</li>
<li class="body">
It defines an <span class="code">ejbCreate&lt;METHOD&gt;()</span> method this is
<span class="code">public</span>, not <span class="code">final</span>,
not <span class="code">static</span>, and has
return type <span class="code">void</span>.
</li>
</ul>
<p class="body">
Reference: Enterprise JavaBeans&trade; Specification,Version 2.0, section 7.10.
</p>
<h4>Example</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;j2ee.SessionBean&quot;/&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.j2ee
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<!-- --><a name="ThisParameter"></a> <h2>ThisParameter</h2> <h4>Description</h4>
<p class="body">
Checks that <span class="code">this</span> is not a parameter of any method calls or constructors for a bean.
Instead, you must use the result of the <span class="code">getEJBObject()</span> available in
<span class="code">SessionContext</span> or <span class="code">EntityContext</span>.
</p>
<p class="body">
Reference: <a href="http://www.javaworld.com/javaworld/jw-08-2000/jw-0825-ejbrestrict.html">Programming restrictions on EJB</a>.
</p>
<h4>Example</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;j2ee.ThisParameter&quot;/&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.j2ee
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<!-- --><a name="ThisReturn"></a> <h2>ThisReturn</h2> <h4>Description</h4>
<p class="body">
Checks that <span class="code">this</span> is not returned by a bean method.
Instead, you must use the result of the <span class="code">getEJBObject()</span> available in
<span class="code">SessionContext</span> or <span class="code">EntityContext</span>.
</p>
<p class="body">
Reference: <a href="http://www.javaworld.com/javaworld/jw-08-2000/jw-0825-ejbrestrict.html">Programming restrictions on EJB</a>.
</p>
<h4>Example</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;j2ee.ThisReturn&quot;/&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.j2ee
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
</td>
</tr>
</table>
<hr />
<div><a href="index.html">Back to the Checkstyle Home Page</a></div>
<p class="copyright">
Copyright &copy; 2002-2004 Oliver Burn. All rights Reserved.
</p>
</body>
</html>

View File

@ -1,597 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Checks for Javadoc Comments</title>
<link rel="stylesheet" type="text/css" href="mystyle.css"/>
</head>
<body>
<!-- The header -->
<table border="0" width="100%" summary="header layout">
<tr>
<td><h1>Checks for Javadoc Comments</h1></td>
<td align="right"><img src="logo.png" alt="Checkstyle Logo"/></td>
</tr>
</table>
<!-- content -->
<table border="0" width="100%" cellpadding="5" summary="body layout">
<tr>
<!--Left menu-->
<td class="menu" valign="top">
<ul>
<li>
<a href="#PackageHtml">PackageHtml</a>
</li>
<li>
<a href="#JavadocType">JavadocType</a>
</li>
<li>
<a href="#JavadocMethod">JavadocMethod</a>
</li>
<li>
<a href="#JavadocVariable">JavadocVariable</a>
</li>
<li>
<a href="#JavadocStyle">JavadocStyle</a>
</li>
</ul>
</td>
<!--Content-->
<td class="content" valign="top" align="left">
<a name="PackageHtml"></a> <h2>PackageHtml</h2> <h4>Description</h4>
<p class="body">
Checks that a <span class="code">package.html</span> file exists for each
package. More specifically, checks that each java file has a package.html sibling.
</p>
<h4 class="body">Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>fileExtensions</td>
<td>file type extension to identify java files. Setting this property is
typically only required if your java source files are preprocessed
and the original files do not have the extension
<span class="code">.java</span></td>
<td><a href="property_types.html#stringSet">String Set</a></td>
<td><span class="default">java</span></td>
</tr>
</table>
<h4>Example</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name="PackageHtml"/&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.javadoc
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#checker">Checker</a>
</p>
<a name="JavadocType"></a> <h2>JavadocType</h2> <h4>Description</h4>
<p class="body">
Checks Javadoc comments for class and interface definitions.
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>scope</td>
<td>visibility scope where Javadoc comments are checked</td>
<td><a href="property_types.html#scope">scope</a></td>
<td><span class="default">private</span></td>
</tr>
<tr>
<td>excludeScope</td>
<td>visibility scope where Javadoc comments are not checked</td>
<td><a href="property_types.html#scope">scope</a></td>
<td><span class="default">null</span></td>
</tr>
<tr>
<td>authorFormat</td>
<td>pattern for @author tag</td>
<td><a href="property_types.html#regexp">regular expression</a></td>
<td><span class="default">null</span> (tag not required)</td>
</tr>
<tr>
<td>versionFormat</td>
<td>pattern for @version tag</td>
<td><a href="property_types.html#regexp">regular expression</a></td>
<td><span class="default">null</span> (tag not required)</td>
</tr>
<tr>
<td>tokens</td>
<td>definitions to check</td>
<td>subset of tokens <a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#INTERFACE_DEF">INTERFACE_DEF</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CLASS_DEF">CLASS_DEF</a></td>
<td><a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#INTERFACE_DEF">INTERFACE_DEF</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CLASS_DEF">CLASS_DEF</a>,</td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the default check:
</p>
<pre class="body">
&lt;module name="JavadocType"/&gt;
</pre>
<p class="body">
To configure the check for <span class="default">public</span> scope:
</p>
<pre class="body">
&lt;module name="JavadocType"&gt;
&lt;property name="scope" value="public"/&gt;
&lt;/module&gt;
</pre>
<p class="body">
To configure the check for an @author tag:
</p>
<pre class="body">
&lt;module name="JavadocType"&gt;
&lt;property name="authorFormat" value="\S"/&gt;
&lt;/module&gt;
</pre>
<p class="body">
To configure the check for a CVS revision version tag:
</p>
<pre class="body">
&lt;module name="JavadocType"&gt;
&lt;property name="versionFormat" value="\$Revision.*\$"/&gt;
&lt;/module&gt;
</pre>
<p class="body">
To configure the check for <span
class="default">private</span> classes only:
</p>
<pre class="body">
&lt;module name="JavadocType"&gt;
&lt;property name="scope" value="private"/&gt;
&lt;property name="excludescope" value="package"/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.javadoc
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<a name="JavadocMethod"></a> <h2>JavadocMethod</h2> <h4>Description</h4>
<p class="body">
Checks to ensure that the following tags exist (if required):
</p>
<ul class="body">
<li>
<span class="code">@return</span>
</li>
<li>
<span class="code">@param</span>
</li>
<li>
<span class="code">@throws</span> or <span class="code">@exception</span>
</li>
<li>
<span class="code">@see</span> or <span class="code">{@inheritDoc}</span>
</li>
</ul>
<p class="body">
For example, the following is valid:
</p>
<a name="checkReturnTag"></a>
<pre class="body">
/**
* Checks for a return tag.
* @return the index of the next unchecked tag
* @param aTagIndex the index to start in the tags
* @param aTags the tags to check
* @param aLineNo the line number of the expected tag
**/
public int checkReturnTag(final int aTagIndex,
JavadocTag[] aTags,
int aLineNo)
</pre>
<p class="body">
This supports the convention in the <a href="http://java.sun.com/j2se/javadoc/writingdoccomments/index.html#throwstag">Sun
Javadoc Guidelines</a> and the "Effective Java" book.
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>scope</td>
<td>visibility scope where Javadoc comments are checked</td>
<td><a href="property_types.html#scope">scope</a></td>
<td><span class="default">private</span></td>
</tr>
<tr>
<td>excludeScope</td>
<td>visibility scope where Javadoc comments are not checked</td>
<td><a href="property_types.html#scope">scope</a></td>
<td><span class="default">null</span></td>
</tr>
<tr>
<td>allowUndeclaredRTE</td>
<td>whether to allow documented exceptions that
are not declared if they are a subclass of <span
class="code">java.lang.RuntimeException</span></td>
<td><a href="property_types.html#boolean">boolean</a></td>
<td><span class="default">false</span></td>
</tr>
<tr>
<td>allowThrowsTagsForSubclasses</td>
<td>whether to allow documented exceptions that
are subclass of one of declared exception.</td>
<td><a href="property_types.html#boolean">boolean</a></td>
<td><span class="default">false</span></td>
</tr>
<tr>
<td>allowMissingParamTags</td>
<td>whether to ignore errors when a method has parameters
but does not have matching param tags in the javadoc.</td>
<td><a href="property_types.html#boolean">boolean</a></td>
<td><span class="default">false</span></td>
</tr>
<tr>
<td>allowMissingThrowsTags</td>
<td>whether to ignore errors when a method declares
that it throws exceptions but does have matching throws tags
in the javadoc.</td>
<td><a href="property_types.html#boolean">boolean</a></td>
<td><span class="default">false</span></td>
</tr>
<tr>
<td>allowMissingReturnTag</td>
<td>whether to ignore errors when a method returns
non-void type does have a return tag in the javadoc.</td>
<td><a href="property_types.html#boolean">boolean</a></td>
<td><span class="default">false</span></td>
</tr>
<tr>
<td>tokens</td>
<td>definitions to check</td>
<td>subset of tokens <a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#METHOD_DEF">METHOD_DEF</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CTOR_DEF">CTOR_DEF</a></td>
<td><a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#METHOD_DEF">METHOD_DEF</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CTOR_DEF">CTOR_DEF</a></td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the default check:
</p>
<pre class="body">
&lt;module name="JavadocMethod"/&gt;
</pre>
<p class="body">
To configure the check for <span class="default">public</span>
scope and to allow documentation of undeclared RuntimeExceptions:
</p>
<pre class="body">
&lt;module name="JavadocMethod"&gt;
&lt;property name="scope" value="public"/&gt;
&lt;property name="allowUndeclaredRTE" value="true"/&gt;
&lt;/module&gt;
</pre>
<p class="body">
To configure the check for methods which are in <span
class="default">private</span> , but not in <span
class="default">protected</span> scope:
</p>
<pre class="body">
&lt;module name="JavadocMethod"&gt;
&lt;property name="scope" value="private"/&gt;
&lt;property name="excludeScope" value="protected"/&gt;
&lt;/module&gt;
</pre>
<h4>Notes</h4>
<ul class="body">
<li>The classpath may need to be configured to locate the class information. The
classpath configuration is dependent on the mechanism used to invoke Checkstyle.
</li>
<li>
It can be extremely painful writing or duplicating Javadoc for a
method required for an interface. Hence checkstyle supports using the
convention of using a
single <span class="code">@see</span> or <span class="code">{@inheritDoc}</span> tag instead of all the other tags. For
example, if the <a href="#checkReturnTag">above method</a> was implementing a method required by the <span class="code">
com.puppycrawl.tools.checkstyle.Verifier</span> interface, then the Javadoc
could be done as:
<pre class="body">
/** @see com.puppycrawl.tools.checkstyle.Verifier **/
public int checkReturnTag(final int aTagIndex,
JavadocTag[] aTags,
int aLineNo)
</pre>
or:
<pre class="body">
/** {@inheritDoc} **/
public int checkReturnTag(final int aTagIndex,
JavadocTag[] aTags,
int aLineNo)
</pre>
</li>
</ul>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.javadoc
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<a name="JavadocVariable"></a> <h2>JavadocVariable</h2> <h4>Description</h4>
<p class="body">
Checks that variables have Javadoc comments.
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>scope</td>
<td>visibility scope where Javadoc comments are checked</td>
<td><a href="property_types.html#scope">scope</a></td>
<td><span class="default">private</span></td>
</tr>
<tr>
<td>excludeScope</td>
<td>visibility scope where Javadoc comments are not checked</td>
<td><a href="property_types.html#scope">scope</a></td>
<td><span class="default">null</span></td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the default check:
</p>
<pre class="body">
&lt;module name="JavadocVariable"/&gt;
</pre>
<p class="body">
To configure the check for <span class="default">public</span> scope:
</p>
<pre class="body">
&lt;module name="JavadocVariable"&gt;
&lt;property name="scope" value="public"/&gt;
&lt;/module&gt;
</pre>
<p class="body">
To configure the check for members which are in <span
class="default">private</span>, but not in <span
class="default">protected</span> scope:
</p>
<pre class="body">
&lt;module name="JavadocVariable"&gt;
&lt;property name="scope" value="private"/&gt;
&lt;property name="excludeScope" value="protected"/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.javadoc
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<a name="JavadocStyle"></a>
<h2>JavadocStyle</h2>
<h4>Description</h4>
<p class="body">
Validates Javadoc comments to help ensure they are well formed.
The following checks are performed:
</p>
<ul>
<li> Ensures the first sentence ends with proper punctuation (That
is a period, question mark, or exclamation mark). Javadoc
automatically places the first sentence in the method summary table
and index. With out proper punctuation the Javadoc may be
malformed.
</li>
<li> Check text for Javadoc statements that do not have any description.
This includes both completely empty Javadoc, and Javadoc with only
tags such as @param and @return.</li>
<li> Check text for incomplete HTML tags. Verifies that HTML tags
have corresponding end tags and issues an "Unclosed HTML tag found:"
error if not. An "Extra HTML tag found:" error is issued if an end
tag is found without a previous open tag.</li>
</ul>
<p>These checks were patterned after the checks made by the <a
href="http://java.sun.com/j2se/javadoc/doccheck/index.html">DocCheck</a>
doclet available from Sun. </p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>scope</td>
<td>visibility scope where Javadoc comments are checked</td>
<td><a href="property_types.html#scope">scope</a></td>
<td><span class="default">private</span></td>
</tr>
<tr>
<td>excludeScope</td>
<td>visibility scope where Javadoc comments are not checked</td>
<td><a href="property_types.html#scope">scope</a></td>
<td><span class="default">null</span></td>
</tr>
<tr>
<td>checkFirstSentence</td>
<td>Whether to check the first sentence for proper end of sentence.</td>
<td><a href="property_types.html#boolean">boolean</a></td>
<td><span class="default">true</span></td>
</tr>
<tr>
<td>checkEmptyJavadoc</td>
<td>Whether to check if the Javadoc is missing a describing text.</td>
<td><a href="property_types.html#boolean">boolean</a></td>
<td><span class="default">false</span></td>
</tr>
<tr>
<td>checkHtml</td>
<td>Whether to check for incomplete html tags.</td>
<td><a href="property_types.html#boolean">boolean</a></td>
<td><span class="default">true</span></td>
</tr>
<tr>
<td>tokens</td>
<td>definitions to check</td>
<td>subset of tokens
<a href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#INTERFACE_DEF">INTERFACE_DEF</a>,
<a href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CLASS_DEF">CLASS_DEF</a>,
<a href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#METHOD_DEF">METHOD_DEF</a>,
<a href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CTOR_DEF">CTOR_DEF</a>,
<a href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#VARIABLE_DEF">VARIABLE_DEF</a>
</td>
<td>
<a href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#INTERFACE_DEF">INTERFACE_DEF</a>,
<a href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CLASS_DEF">CLASS_DEF</a>,
<a href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#METHOD_DEF">METHOD_DEF</a>,
<a href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CTOR_DEF">CTOR_DEF</a>,
<a href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#VARIABLE_DEF">VARIABLE_DEF</a>
</td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the default check:
</p>
<pre class="body">
&lt;module name="JavadocStyle"/&gt;
</pre>
<p class="body">
To configure the check for <span class="default">public</span> scope:
</p>
<pre class="body">
&lt;module name="JavadocStyle"&gt;
&lt;property name="scope" value="public"/&gt;
&lt;/module&gt;
</pre>
<p class="body">
To configure the check for javadoc which is in <span
class="default">private</span>, but not in <span
class="default">package</span> scope:
</p>
<pre class="body">
&lt;module name="JavadocStyle"&gt;
&lt;property name="scope" value="private"/&gt;
&lt;property name="excludeScope" value="package"/&gt;
&lt;/module&gt;
</pre>
<p class="body">
To configure the check to turn off first sentence checking:
</p>
<pre class="body">
&lt;module name="JavadocStyle"&gt;
&lt;property name="checkFirstSentence" value="false"/&gt;
&lt;/module&gt;
</pre>
<p class="body">
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
</td>
</tr>
</table>
<hr />
<div><a href="index.html">Back to the Checkstyle Home Page</a></div>
<p class="copyright">
Copyright &copy; 2002-2004 Oliver Burn. All rights Reserved.
</p>
</body>
</html>

View File

@ -1,436 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Metrics Checks</title>
<link rel="stylesheet" type="text/css" href="mystyle.css"/>
</head>
<body>
<!-- The header -->
<table border="0" width="100%" summary="header layout">
<tr>
<td><h1>Metrics Checks</h1></td>
<td align="right"><img src="logo.png" alt="Checkstyle Logo"/></td>
</tr>
</table>
<!-- content -->
<table border="0" width="100%" cellpadding="5" summary="body layout">
<tr>
<!--Left menu-->
<td class="menu" valign="top">
<ul>
<li><a href="#BooleanExpressionComplexity">BooleanExpressionComplexity</a></li>
<li><a href="#ClassDataAbstractionCoupling">ClassDataAbstractionCoupling</a></li>
<li><a href="#ClassFanOutComplexity">ClassFanOutComplexity</a></li>
<li><a href="#CyclomaticComplexity">CyclomaticComplexity</a></li>
<li><a href="#JavaNCSS">JavaNCSS</a></li>
<li><a href="#NPathComplexity">NPathComplexity</a></li>
</ul>
</td>
<!--Content-->
<td class="content" valign="top" align="left">
<!-- --><a name="BooleanExpressionComplexity"></a>
<h2>BooleanExpressionComplexity</h2>
<h4>Description</h4>
<p class="body">
Restrict the number of number of <span class="code">&&</span>,
<span class="code">||</span> and <span class="code">^</span> in
an expression.
</p>
<p>
Rationale:
Too many conditions leads to code that is difficult to
read and hence debug and maintain.
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>max</td>
<td>the maximum allowed number of boolean operations in one
experession.</td>
<td><a href="property_types.html#integer">integer</a></td>
<td><span class="default">3</span></td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;BooleanExpressionComplexity&quot;/&gt;
</pre>
<p class="body">
To configure the check with 7 allowed operation in boolean expression:
</p>
<pre class="body">
&lt;module name=&quot;BooleanExpressionComplexity&quot;&gt;
&lt;property name=&quot;max&quot; value=&quot;7&quot;/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.metrics
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<!-- --><a name="ClassDataAbstractionCoupling"></a> <h2>ClassDataAbstractionCoupling</h2>
<h4>Description</h4>
<p class="body">
This metric measures the number of instantiations of
other classes within the given class. This type of
coupling is not caused by inheritance or the object
oriented paradigm. Generally speaking, any abstract
data type with other abstract data types as members has
data abstraction coupling; therefore, if a class has a
local variable that is an instantiation (object) of
another class, there is data abstraction coupling. The
higher the DAC, the more complex the data structure
(classes) of the system.
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>max</td>
<td>the maximum threshold allowed</td>
<td><a href="property_types.html#integer">integer</a></td>
<td><span class="default">7</span></td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;ClassDataAbstractionCoupling&quot;/&gt;
</pre>
<p class="body">
To configure the check with a threshold of 5:
</p>
<pre class="body">
&lt;module name=&quot;ClassDataAbstractionCoupling&quot;&gt;
&lt;property name=&quot;max&quot; value=&quot;5&quot;/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.metrics
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<!-- --><a name="ClassFanOutComplexity"></a> <h2>ClassFanOutComplexity</h2>
<h4>Description</h4>
<p class="body">
The number of other classes a given class relies on. Also
the square of this has been shown to indicate the
amount of maintenence required in functional programs
(on a file basis) at least.
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>max</td>
<td>the maximum threshold allowed</td>
<td><a href="property_types.html#integer">integer</a></td>
<td><span class="default">20</span></td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;ClassFanOutComplexity&quot;/&gt;
</pre>
<p class="body">
To configure the check with a threshold of 10:
</p>
<pre class="body">
&lt;module name=&quot;ClassFanOutComplexity&quot;&gt;
&lt;property name=&quot;max&quot; value=&quot;10&quot;/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.metrics
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<!-- --><a name="CyclomaticComplexity"></a> <h2>CyclomaticComplexity</h2>
<h4>Description</h4>
<p class="body">
Checks cyclomatic complexity against a specified limit. The complexity is
measured by the number of
<span CLASS="code">if</span>,
<span CLASS="code">while</span>,
<span CLASS="code">do</span>,
<span CLASS="code">for</span>,
<span CLASS="code">?:</span>,
<span CLASS="code">catch</span>,
<span CLASS="code">switch</span>,
<span CLASS="code">case</span> statements, and operators
<span CLASS="code">&&</span> and <span CLASS="code">||</span> (plus one) in the body of a
constructor, method, static initializer, or instance initializer.
It is a measure of the minimum number of possible paths through the
source and therefore the number of required tests. Generally 1-4 is
considered good, 5-7 ok, 8-10 consider re-factoring, and 11+ re-factor now!
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>max</td>
<td>the maximum threshold allowed</td>
<td><a href="property_types.html#integer">integer</a></td>
<td><span class="default">10</span></td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;CyclomaticComplexity&quot;/&gt;
</pre>
<p class="body">
To configure the check with a threshold of 7:
</p>
<pre class="body">
&lt;module name=&quot;CyclomaticComplexity&quot;&gt;
&lt;property name=&quot;max&quot; value=&quot;7&quot;/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.metrics
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<!-- --><a name="NPathComplexity"></a> <h2>NPathComplexity</h2>
<h4>Description</h4>
<p class="body">
The NPATH metric computes the number of possible
execution paths through a function. It takes into
account the nesting of conditional statements and
multi-part boolean expressions (e.g., A && B, C || D,
etc.).
</p>
<p>
Rationale:
Nejmeh says that his group had an informal NPATH limit
of 200 on individual routines; functions that exceeded
this value were candidates for further decomposition -
or at least a closer look.
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>max</td>
<td>the maximum threshold allowed</td>
<td><a href="property_types.html#integer">integer</a></td>
<td><span class="default">200</span></td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;NPathComplexity&quot;/&gt;
</pre>
<p class="body">
To configure the check with a threshold of 20:
</p>
<pre class="body">
&lt;module name=&quot;NPathComplexity&quot;&gt;
&lt;property name=&quot;max&quot; value=&quot;20&quot;/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.metrics
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<!-- --><a name="JavaNCSS"></a>
<h2>JavaNCSS</h2>
<h4>Description</h4>
<p class="body">
Determines complexity of methods, classes and files by counting
the Non Commenting Source Statements (NCSS).
This check adheres to the <a
href="http://www.kclee.com/clemens/java/javancss/">
specification</a> for the JavaNCSS-Tool written by
<b>Chr. Clemens Lee</b> which sadly seems to have been pulled
off the web.<br/>
Rougly said the NCSS metric is calculated by counting the source
lines which are not comments, (nearly) equivalent to counting
the semicolons and opening curly braces.<br/>
The NCSS for a class is summarized from the NCSS of all its methods,
the NCSS of its nested classes and the number of member variable
declarations.<br/>
The NCSS for a file is summarized from the ncss of all its top level
classes, the number of imports and the package declaration.
</p>
<p>
Rationale:
Too large methods and classes are hard to read and costly to
maintain. A large NCSS number often means that a method or
class has too many responsabilities and/or functionalities
which should be decomposed into smaller units.
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>methodMaximum</td>
<td>the maximum allowed number of non commenting lines in
a method.</td>
<td><a href="property_types.html#integer">integer</a></td>
<td><span class="default">50</span></td>
</tr>
<tr>
<td>classMaximum</td>
<td>the maximum allowed number of non commenting lines in
a class.</td>
<td><a href="property_types.html#integer">integer</a></td>
<td><span class="default">1500</span></td>
</tr>
<tr>
<td>fileMaximum</td>
<td>the maximum allowed number of non commenting lines in
a file including all top level and nested classes.</td>
<td><a href="property_types.html#integer">integer</a></td>
<td><span class="default">2000</span></td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;JavaNCSS&quot;/&gt;
</pre>
<p class="body">
To configure the check with 40 allowed non commenting lines
for a method:
</p>
<pre class="body">
&lt;module name=&quot;JavaNCSS&quot;&gt;
&lt;property name=&quot;methodMaximum&quot; value=&quot;40&quot;/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.metrics
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
</td>
</tr>
</table>
<hr />
<div><a href="index.html">Back to the Checkstyle Home Page</a></div>
<p class="copyright">
Copyright &copy; 2002-2004 Oliver Burn. All rights Reserved.
</p>
</body>
</html>

View File

@ -1,930 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Miscellaneous Checks</title>
<link rel="stylesheet" type="text/css" href="mystyle.css"/>
</head>
<body>
<!-- The header -->
<table border="0" width="100%" summary="header layout">
<tr>
<td><h1>Miscellaneous Checks</h1></td>
<td align="right"><img src="logo.png" alt="Checkstyle Logo"/></td>
</tr>
</table>
<!-- content -->
<table border="0" width="100%" cellpadding="5" summary="body layout">
<tr>
<!--Left menu-->
<td class="menu" valign="top">
<ul>
<li>
<a href="#ArrayTypeStyle">ArrayTypeStyle</a>
</li>
<li>
<a href="#DescendantToken">DescendantToken</a>
</li>
<li>
<a href="#FinalParameters">FinalParameters</a>
</li>
<li>
<a href="#GenericIllegalRegexp">GenericIllegalRegexp</a>
</li>
<li>
<a href="#Indentation">Indentation</a>
</li>
<li>
<a href="#NewlineAtEndOfFile">NewlineAtEndOfFile</a>
</li>
<li>
<a href="#RequiredRegexp">RequiredRegexp</a>
</li>
<li>
<a href="#TodoComment">TodoComment</a>
</li>
<li>
<a href="#TrailingComment">TrailingComment</a>
</li>
<li>
<a href="#Translation">Translation</a>
</li>
<li>
<a href="#UncommentedMain">UncommentedMain</a>
</li>
<li>
<a href="#UpperEll">UpperEll</a>
</li>
</ul>
</td>
<!--Content-->
<td class="content" valign="top" align="left">
<!-- --> <a name="GenericIllegalRegexp"></a> <h2>GenericIllegalRegexp</h2> <h4>Description</h4>
<p class="body">
A generic check for code problems - the user can search for any pattern. This is
similar to a recursive grep, only that it's integrated in checkstyle.
</p>
<p class="body">
Rationale: This check can be used to prototype checks and to find common bad
practice such as calling <span class="code">ex.printStacktrace()</span>, <span class="code">
System.out.println()</span>, <span class="code">System.exit()</span>, etc.
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>format</td>
<td>illegal pattern</td>
<td><a href="property_types.html#regexp">regular expression</a></td>
<td><span class="default">^$</span> (empty)</td>
</tr>
<tr>
<td>ignoreCase</td>
<td>Controls whether to ignore case when searching.</td>
<td><a href="property_types.html#boolean">Boolean</a></td>
<td><span class="default">false</span></td>
</tr>
<tr>
<td>ignoreComments</td>
<td>Controls whether to ignore text in comments when searching.</td>
<td><a href="property_types.html#boolean">Boolean</a></td>
<td><span class="default">false</span></td>
</tr>
<tr>
<td>message</td>
<td>message which is used to notify about violations,
if empty then default(hard-coded) message is used.</td>
<td><a href="property_types.html#String">String</a></td>
<td><span class="default">&quot;&quot;</span>(empty)</td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check for calls to <span class="code">System.out.println</span>:
</p>
<pre class="body">
&lt;module name=&quot;GenericIllegalRegexp&quot;&gt;
&lt;!-- . matches any character, so we need to
escape it and use \. to match dots. --&gt;
&lt;property name=&quot;format&quot; value=&quot;System\.out\.println&quot;/&gt;
&lt;/module&gt;
</pre>
<p class="body">
To configure the check to find trailing whitespace at the end of a line:
</p>
<pre class="body">
&lt;module name=&quot;GenericIllegalRegexp&quot;&gt;
&lt;!-- \s matches whitespace character, $ matches end of line. --&gt;
&lt;property name=&quot;format&quot; value=&quot;\s$&quot;/&gt;
&lt;/module&gt;
</pre>
<p class="body">
To configure the check to find case-insensitive occurrences of &quot;debug&quot;:
</p>
<pre class="body">
&lt;module name=&quot;GenericIllegalRegexp&quot;&gt;
&lt;property name=&quot;format&quot; value=&quot;debug&quot;/&gt;
&lt;property name=&quot;ignoreCase&quot; value=&quot;true&quot;/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<!-- --> <a name="NewlineAtEndOfFile"></a> <h2>NewlineAtEndOfFile</h2> <h4>Description</h4>
<p class="body">
Checks whether files end with a new line.
</p>
<p class="body">
Rationale: Any source files and text files in general should end with a newline
character, especially when using SCM systems such as CVS. CVS will even
print a warning when it encounters a file that doesn't end with a newline.
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>lineSeparator</td>
<td>type of line separator</td>
<td>One of &quot;system&quot; (system default), &quot;crlf&quot; (Windows-style), &quot;cr&quot; (Mac-style) and &quot;lf&quot; (Unix-style)</td>
<td>system default</td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;NewlineAtEndOfFile&quot;/&gt;
</pre>
<p class="body">
To configure the check to always use Unix-style line separators:
</p>
<pre class="body">
&lt;module name=&quot;NewlineAtEndOfFile&quot;&gt;
&lt;property name=&quot;lineSeparator&quot; value=&quot;lf&quot;/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#checker">Checker</a>
</p>
<!-- --> <a name="TodoComment"></a> <h2>TodoComment</h2> <h4>Description</h4>
<p class="body">
A check for <span class="code">TODO:</span> comments. Actually it is a generic <a href="http://jakarta.apache.org/regexp/apidocs/org/apache/regexp/RE.html">regular
expression</a> matcher on Java comments. To check for other patterns in Java
comments, set property format.
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>format</td>
<td>pattern to check</td>
<td><a href="property_types.html#regexp">regular expression</a></td>
<td><span class="default">TODO:</span></td>
</tr>
</table>
<h4>Notes</h4>
<p class="body">
Using <span class="code">TODO:</span> comments is a great way to keep track of
tasks that need to be done. Having them reported by Checkstyle makes it very
hard to forget about them.
</p>
<h4>Examples</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;TodoComment&quot;/&gt;
</pre>
<p class="body">
To configure the check for comments that contain <span class="code">WARNING</span>:
</p>
<pre class="body">
&lt;module name=&quot;TodoComment&quot;&gt;
&lt;property name=&quot;format&quot; value=&quot;WARNING&quot;/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<!-- --> <a name="Translation"></a> <h2>Translation</h2> <h4>Description</h4>
<p class="body">
A <a href="config.html#overview">FileSetCheck</a> that ensures the correct
translation of code by checking property files for consistency regarding their
keys. Two property files describing one and the same context are consistent if
they contain the same keys.
</p>
<p class="body">
Consider the following properties file in the same directory:
</p>
<pre>
#messages.properties
hello=Hello
cancel=Cancel
#messages_de.properties
hell=Hallo
ok=OK
</pre>
<p class="body">
The Translation check will find the typo in the german hello key, the
missing ok key in the default resource file and the missing cancel key
in the german resource file:
</p>
<pre>
messages_de.properties: Key 'hello' missing.
messages_de.properties: Key 'cancel' missing.
messages.properties: Key 'hell' missing.
messages.properties: Key 'ok' missing.
</pre>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>fileExtensions</td>
<td>file type extension to identify translation files. Setting this property
is typically only required if your translation files are preprocessed
and the original files do not have the extension
<span class="code">.properties</span></td>
<td><a href="property_types.html#stringSet">String Set</a></td>
<td><span class="default">properties</span></td>
</tr>
</table>
<h4>Example</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;Translation&quot;/&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#checker">Checker</a>
</p>
<!-- --> <a name="UncommentedMain"></a> <h2>UncommentedMain</h2> <h4>Description</h4>
<p class="body">
Checks for uncommented main() methods (debugging leftovers).
</p>
<p class="body"> Rationale: A main() method is often used for
debug puposes. When debugging is finished, developers often forget
to remove the method, which changes the API and increases the size
of the resulting class/jar file. With the exception of the real
program entry points, all main() methods should be removed/commented
out of the sources.
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>excludedClasses</td>
<td>pattern for qualified names of classes which are allowed
to have a main method.</td>
<td><a href="property_types.html#regexp">regular expression</a></td>
<td><span class="default">^$</span></td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;UncommentedMain&quot;/&gt;
</pre>
<p class="body">
To configure the check to allow main method for all classes with
&quot;Main&quot; name:
</p>
<pre class="body">
&lt;module name=&quot;UncommentedMain&quot;&gt;
&lt;property name=&quot;excludedClasses&quot; value=&quot;\.Main$&quot;/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<!-- --> <a name="UpperEll"></a> <h2>UpperEll</h2> <h4>Description</h4>
<p class="body">
Checks that long constants are defined with an upper ell. That is <span class="code">'
L'</span> and
not <span class="code">'l'</span>. This is in accordance to the Java Language
Specification, <a href="http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html#48282">
Section
3.10.1</a>.
</p>
<p class="body"> Rationale: The letter <span class="code">l</span> looks a lot
like <span class="code">1</span>.
</p>
<h4>Examples</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;UpperEll&quot;/&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<!-- --> <a name="ArrayTypeStyle"></a> <h2>ArrayTypeStyle</h2> <h4>Description</h4>
<p class="body">
Checks the style of array type definitions.
Some like Java-style: <code>public static void main(String[] args)</code>
and some like C-style: public static void main(String args[])
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>javaStyle</td>
<td>Controls whether to enforce Java style (true) or C style (false).</td>
<td><a href="property_types.html#boolean">Boolean</a></td>
<td><span class="default">true</span></td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check to enforce Java style:
</p>
<pre class="body">
&lt;module name=&quot;ArrayTypeStyle&quot;/&gt;
</pre>
<p class="body">
To configure the check to enforce C style:
</p>
<pre class="body">
&lt;module name=&quot;ArrayTypeStyle&quot;&gt;
&lt;property name=&quot;javaStyle&quot; value=&quot;false&quot;/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<!-- --> <a name="FinalParameters"></a> <h2>FinalParameters</h2> <h4>Description</h4>
<p class="body">
Check that method/constructor/catch block parameters are final. Interface and abstract methods are not checked -
the final keyword does not make sense for interface and abstract method parameters as there is no code
that could modify the parameter.
</p>
<p class="body">
Rationale: Changing the value of parameters during the execution of the
method's algorithm can be confusing and should be avoided. A great way to
let the Java compiler prevent this coding style is to declare parameters
final.
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>tokens</td>
<td>blocks to check</td>
<td>subset of tokens <a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#METHOD_DEF">METHOD_DEF</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CTOR_DEF">CTOR_DEF</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_CATCH">LITERAL_CATCH</a></td>
<td><a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#METHOD_DEF">METHOD_DEF</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CTOR_DEF">CTOR_DEF</a></td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check to enforce final parameters for methods and constructors:
</p>
<pre class="body">
&lt;module name=&quot;FinalParameters&quot;/&gt;
</pre>
<p class="body">
To configure the check to enforce final parameters only for constructors:
</p>
<pre class="body">
&lt;module name=&quot;FinalParameters&quot;&gt;
&lt;property name=&quot;tokens&quot; value=&quot;CTOR_DEF&quot;/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<!-- --> <a name="DescendantToken"></a> <h2>DescendantToken</h2> <h4>Description</h4>
<p class="body">
Checks for restricted tokens beneath other tokens.
</p>
<p class="body">
WARNING: This is a very powerful and flexible check, but, at the
same time, it is low level and very implementation dependent
because its results depend on the grammar we use to build abstract
syntax trees. Thus we recomend using other checks when
they provide the desired funcionality. All in all, this check just
works on the level of an abstract tree and knows nothing about language
structures.
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>tokens</td>
<td>token types to check</td>
<td>subset of tokens declared in <a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html">TokenTypes</a></td>
<td>empty set</td>
</tr>
<tr>
<td>limitedTokens</td>
<td>set of tokens with limited occurances as descendants</td>
<td>subset of tokens declared in <a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html">TokenTypes</a></td>
<td>empty set</td>
<tr>
<td>minimumDepth</td>
<td>the mimimum depth for descendant counts</td>
<td><a href="property_types.html#integer">Integer</a></td>
<td>0</td>
</tr>
<tr>
<td>maximumDepth</td>
<td>the maximum depth for descendant counts</td>
<td><a href="property_types.html#integer">Integer</a></td>
<td>java.lang.Integer.MAX_VALUE</td>
</tr>
<tr>
<td>minimumNumber</td>
<td>a minimum count for descendants</td>
<td><a href="property_types.html#integer">Integer</a></td>
<td>0</td>
</tr>
<tr>
<td>maximumNumber</td>
<td>a maximum count for descendants</td>
<td><a href="property_types.html#integer">Integer</a></td>
<td>java.lang.Integer.MAX_VALUE</td>
</tr>
<tr>
<td>minimumMessage</td>
<td>error message when minimum count not reached</td>
<td><a href="property_types.html#String">String</a></td>
<td>&quot;descendant.token.min&quot;</td>
</tr>
<tr>
<td>maximumMessage</td>
<td>error message when maximum count exceeded</td>
<td><a href="property_types.html#String">String</a></td>
<td>&quot;descendant.token.max&quot;</td>
</tr>
</table>
<h4>Examples</h4>
<pre>
String literal equality check:
&lt;module name="DescendantToken"&gt;
&lt;property name="tokens" value="EQUAL,NOT_EQUAL"/&gt;
&lt;property name="limitedTokens" value="STRING_LITERAL"/&gt;
&lt;property name="maximumNumber" value="0"/&gt;
&lt;property name="maximumDepth" value="1"/&gt;
&lt;/module&gt;
Switch with no default:
&lt;module name="DescendantToken"&gt;
&lt;property name="tokens" value="LITERAL_SWITCH"/&gt;
&lt;property name="maximumDepth" value="2"/&gt;
&lt;property name="limitedTokens" value="LITERAL_DEFAULT"/&gt;
&lt;property name="minimumNumber" value="1"/&gt;
&lt;/module&gt;
Assert statement may have side effects (formatted for browser display):
&lt;module name="DescendantToken"&gt;
&lt;property name="tokens" value="LITERAL_ASSERT"/&gt;
&lt;property name="limitedTokens" value="ASSIGN,DEC,INC,POST_DEC,
POST_INC,PLUS_ASSIGN,MINUS_ASSIGN,STAR_ASSIGN,DIV_ASSIGN,MOD_ASSIGN,
BSR_ASSIGN,SR_ASSIGN,SL_ASSIGN,BAND_ASSIGN,BXOR_ASSIGN,BOR_ASSIGN,
METHOD_CALL"/&gt;
&lt;property name="maximumNumber" value="0"/&gt;
&lt;/module&gt;
Initialiser in for performs no setup (use while instead?):
&lt;module name="DescendantToken"&gt;
&lt;property name="tokens" value="FOR_INIT"/&gt;
&lt;property name="limitedTokens" value="EXPR"/&gt;
&lt;property name="minimumNumber" value="1"/&gt;
&lt;/module&gt;
Condition in for performs no check:
&lt;module name="DescendantToken"&gt;
&lt;property name="tokens" value="FOR_CONDITION"/&gt;
&lt;property name="limitedTokens" value="EXPR"/&gt;
&lt;property name="minimumNumber" value="1"/&gt;
&lt;/module&gt;
Switch within switch:
&lt;module name="DescendantToken"&gt;
&lt;property name="tokens" value="LITERAL_SWITCH"/&gt;
&lt;property name="limitedTokens" value="LITERAL_SWITCH"/&gt;
&lt;property name="maximumNumber" value="0"/&gt;
&lt;property name="minimumDepth" value="1"/&gt;
&lt;/module&gt;
Return from within a catch or finally block:
&lt;module name="DescendantToken"&gt;
&lt;property name="tokens" value="LITERAL_FINALLY,LITERAL_CATCH"/&gt;
&lt;property name="limitedTokens" value="LITERAL_RETURN"/&gt;
&lt;property name="maximumNumber" value="0"/&gt;
&lt;/module&gt;
Try within catch or finally block:
&lt;module name="DescendantToken"&gt;
&lt;property name="tokens" value="LITERAL_CATCH,LITERAL_FINALLY"/&gt;
&lt;property name="limitedTokens" value="LITERAL_TRY"/&gt;
&lt;property name="maximumNumber" value="0"/&gt;
&lt;/module&gt;
Too many cases within a switch:
&lt;module name="DescendantToken"&gt;
&lt;property name="tokens" value="LITERAL_SWITCH"/&gt;
&lt;property name="limitedTokens" value="LITERAL_CASE"/&gt;
&lt;property name="maximumDepth" value="2"/&gt;
&lt;property name="maximumNumber" value="10"/&gt;
&lt;/module&gt;
Too many local variables within a method:
&lt;module name="DescendantToken"&gt;
&lt;property name="tokens" value="METHOD_DEF"/&gt;
&lt;property name="limitedTokens" value="VARIABLE_DEF"/&gt;
&lt;property name="maximumDepth" value="2"/&gt;
&lt;property name="maximumNumber" value="10"/&gt;
&lt;/module&gt;
Too many returns from within a method:
&lt;module name="DescendantToken"&gt;
&lt;property name="tokens" value="METHOD_DEF"/&gt;
&lt;property name="limitedTokens" value="LITERAL_RETURN"/&gt;
&lt;property name="maximumNumber" value="3"/&gt;
&lt;/module&gt;
Too many fields within an interface:
&lt;module name="DescendantToken"&gt;
&lt;property name="tokens" value="INTERFACE_DEF"/&gt;
&lt;property name="limitedTokens" value="VARIABLE_DEF"/&gt;
&lt;property name="maximumDepth" value="2"/&gt;
&lt;property name="maximumNumber" value="0"/&gt;
&lt;/module&gt;
Limit the number of exceptions a method can throw:
&lt;module name="DescendantToken"&gt;
&lt;property name="tokens" value="LITERAL_THROWS"/&gt;
&lt;property name="limitedTokens" value="IDENT"/&gt;
&lt;property name="maximumNumber" value="1"/&gt;
&lt;/module&gt;
Limit the number of expressions in a method:
&lt;module name="DescendantToken"&gt;
&lt;property name="tokens" value="METHOD_DEF"/&gt;
&lt;property name="limitedTokens" value="EXPR"/&gt;
&lt;property name="maximumNumber" value="200"/&gt;
&lt;/module&gt;
Disallow empty statements:
&lt;module name="DescendantToken"&gt;
&lt;property name="tokens" value="EMPTY_STAT"/&gt;
&lt;property name="limitedTokens" value="EMPTY_STAT"/&gt;
&lt;property name="maximumNumber" value="0"/&gt;
&lt;property name="maximumDepth" value="0"/&gt;
&lt;property name="maximumMessage"
value="Empty statement is not allowed."/&gt;
&lt;/module&gt;
Too many fields within a class:
&lt;module name="DescendantToken"&gt;
&lt;property name="tokens" value="CLASS_DEF"/&gt;
&lt;property name="limitedTokens" value="VARIABLE_DEF"/&gt;
&lt;property name="maximumDepth" value="2"/&gt;
&lt;property name="maximumNumber" value="10"/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<!-- --> <a name="Indentation">Indentation</a>
<h2>Indentation</h2> <h4>Description</h4>
<p class="body">
Checks correct indentation of Java Code.
</p>
<p class="body">
The basic idea behind this is that while
pretty printers are sometimes convienent for bulk reformats of
legacy code, they often either aren't configurable enough or
just can't anticipate how format should be done. Sometimes this is
personal preference, other times it is practical experience. In any
case, this check should just ensure that a minimal set of indentation
rules are followed.
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>basicOffset</td>
<td>how many spaces to use for new indentation level</td>
<td><a href="property_types.html#integer">Integer</a></td>
<td>4</td>
</tr>
<tr>
<td>braceAdjustment</td>
<td>how far brace should be indented when on next line</td>
<td><a href="property_types.html#integer">Integer</a></td>
<td>0</td>
</tr>
<tr>
<td>caseIndent</td>
<td>how much to indent a case label</td>
<td><a href="property_types.html#integer">Integer</a></td>
<td>4</td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check:
<pre class="body">
&lt;module name=&quot;Indentation&quot;/&gt;
</pre>
</p>
<p class="body">
To configure the check to enforce indentation style recommended
by Sun:
<pre class="body">
&lt;module name=&quot;Indentation&quot;&gt;
&lt;property name=&quot;caseIndent&quot; value=&quot;0&quot;/&gt;
&lt;/module&gt;
</pre>
</p>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.indentation
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<!-- --> <a name="TrailingComment">TrailingComment</a>
<h2>TrailingComment</h2> <h4>Description</h4>
<p class="body">
The check to ensure that requires that comments be the only thing on a line.
For the case of // comments that means that the only thing that should
precede it is whitespace.
It doesn't check comments if they do not end line, i.e. it accept
the following:
<code>Thread.sleep( 10 &lt;some comment here&gt; );</code>
Format property is intended to deal with the "} // while" example.
</p>
<p class="body">
Rationale: Steve McConnel in &quot;Code Complete&quot; suggests that endline
comments are a bad practice. An end line comment would
be one that is on the same line as actual code. For example:
<pre>
a = b + c; // Some insightful comment
d = e / f; // Another comment for this line
</pre>
Quoting &quot;Code Complete&quot; for the justfication:
<ul>
<li>
&quot;The comments have to be aligned so that they do not
interfere with the visual structure of the code. If you don't
align them neatly, they'll make your listing look like it's been
through a washing machine.&quot;
</li>
<li>
&quot;Endline comments tend to be hard to format...It takes time
to align them. Such time is not spent learning more about
the code; it's dedicated solely to the tedious task of
pressing the spacebar or tab key.&quot;
</li>
<li>
&quot;Endline comments are also hard to maintain. If the code on
any line containing an endline comment grows, it bumps the
comment farther out, and all the other endline comments will
have to bumped out to match. Styles that are hard to
maintain aren't maintained....&quot;
</li>
<li>
&quot;Endline comments also tend to be cryptic. The right side of
the line doesn't offer much room and the desire to keep the
comment on one line means the comment must be short.
Work then goes into making the line as short as possible
instead of as clear as possible. The comment usually ends
up as cryptic as possible....&quot;
</li>
<li>
&quot;A systemic problem with endline comments is that it's hard
to write a meaningful comment for one line of code. Most
endline comments just repeat the line of code, which hurts
more than it helps.&quot;
</li>
</ul>
His comments on being hard to maintain when the size of
the line changes are even more important in the age of
automated refactorings.
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>format</td>
<td>pattern for string allowed before comment.</td>
<td><a href="property_types.html#regexp">regular expression</a></td>
<td><span class="default">^[\\s\\}\\);]*$</span></td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check:
<pre class="body">
&lt;module name=&quot;TrailingComment&quot;/&gt;
</pre>
</p>
<p class="body">
To configure the check so it enforces only comment on a line:
<pre class="body">
&lt;module name=&quot;TrailingComment&quot;&gt;
&lt;property name=&quot;format&quot; value=&quot;^\\s*$&quot;/&gt;
&lt;/module&gt;
</pre>
</p>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.indentation
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<!-- --> <a name="RequiredRegexp"></a> <h2>RequiredRegexp</h2> <h4>Description</h4>
<p class="body">
A check that makes sure that a specified pattern exists in the code, e.g. a required
legal text. It does not care about where in the file the pattern is.
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>format</td>
<td>required pattern</td>
<td><a href="property_types.html#regexp">regular expression</a></td>
<td><span class="default">^$</span> (empty)</td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
An example of how to configure the check to make sure a copyright statement
is included in the file:
</p>
<pre class="body">
&lt;module name="RequiredRegexp"&gt;
&lt;property name="format" value="This code is copyrighted"/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
</td>
</tr>
</table>
<hr />
<div><a href="index.html">Back to the Checkstyle Home Page</a></div>
<p class="copyright">
Copyright &copy; 2002-2004 Oliver Burn. All rights Reserved.
</p>
</body>
</html>

View File

@ -1,184 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Modifier Checks</title>
<link rel="stylesheet" type="text/css" href="mystyle.css"/>
</head>
<body>
<!-- The header -->
<table border="0" width="100%" summary="header layout">
<tr>
<td><h1>Modifier Checks</h1></td>
<td align="right"><img src="logo.png" alt="Checkstyle Logo"/></td>
</tr>
</table>
<!-- content -->
<table border="0" width="100%" cellpadding="5" summary="body layout">
<tr>
<!--Left menu-->
<td class="menu" valign="top">
<ul>
<li>
<a href="#ModifierOrder">ModifierOrder</a>
</li>
<li>
<a href="#RedundantModifier">RedundantModifier</a>
</li>
</ul>
</td>
<!--Content-->
<td class="content" valign="top" align="left">
<!-- --><a name="ModifierOrder"></a> <h2>ModifierOrder</h2>
<h4>Description</h4>
<p class="body">
Checks that the order of modifiers conforms to the suggestions in the <a href="http://java.sun.com/docs/books/jls/second_edition/html/classes.doc.html">Java
Language specification, sections 8.1.1, 8.3.1 and 8.4.3</a>. The correct order
is:
</p>
<ol class="body">
<li>
<span class="code">public</span>
</li>
<li>
<span class="code">protected</span>
</li>
<li>
<span class="code">private</span>
</li>
<li>
<span class="code">abstract</span>
</li>
<li>
<span class="code">static</span>
</li>
<li>
<span class="code">final</span>
</li>
<li>
<span class="code">transient</span>
</li>
<li>
<span class="code">volatile</span>
</li>
<li>
<span class="code">synchronized</span>
</li>
<li>
<span class="code">native</span>
</li>
<li>
<span class="code">strictfp</span>
</li>
</ol>
<h4>Example</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;ModifierOrder&quot;/&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<a name="RedundantModifier"></a><h2>RedundantModifier</h2>
<p class="body">
Checks that
<ul class="body">
<li>method declarations in interfaces include neither the <span class="code">
public</span> modifier nor the <span class="code">abstract</span> modifier (see
the <a
href="http://java.sun.com/docs/books/jls/second_edition/html/interfaces.doc.html">Java
Language specification, section 9.4</a>).
</li>
<li>all <span class="code">private</span> method declarations and all method declarations in a
<span class="code">final</span> class do not include modifier
<span class="code">final</span> (see the <a
href="http://java.sun.com/docs/books/jls/second_edition/html/classes.doc.html#11246">Java
Language specification, section 8.4.3.3</a>).</li>
<li>
variable declarations in interfaces include none of the following
modifiers: <span class="code">public</span>, <span class="code">static</span>,
<span class="code">final</span> (variables in interface definitions are constants
and have these modifiers implicitly, see the <a
href="http://java.sun.com/docs/books/jls/second_edition/html/interfaces.doc.html">Java
Language specification, section 9.3</a>).
</li>
</ul>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>tokens</td>
<td>tokens to check</td>
<td>subset of tokens <a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#METHOD_DEF">METHOD_DEF</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#VARIABLE_DEF">VARIABLE_DEF</a></td>
<td><a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#METHOD_DEF">METHOD_DEF</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#VARIABLE_DEF">VARIABLE_DEF</a></td>
</tr>
</table>
<h4>Example</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;RedundantModifier&quot;/&gt;
</pre>
<p class="body">
To configure the check to check only methods and not variables:
</p>
<pre class="body">
&lt;module name=&quot;RedundantModifier&quot;&gt;
&lt;property name=&quot;tokens&quot; value=&quot;METHOD_DEF&quot;/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
</td>
</tr>
</table>
<hr />
<div><a href="index.html">Back to the Checkstyle Home Page</a></div>
<p class="copyright">
Copyright &copy; 2002-2004 Oliver Burn. All rights Reserved.
</p>
</body>
</html>

View File

@ -1,192 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Checks for Naming Conventions</title>
<link rel="stylesheet" type="text/css" href="mystyle.css"/>
</head>
<body>
<!-- The header -->
<table border="0" width="100%" summary="header layout">
<tr>
<td><h1>Checks for Naming Conventions</h1></td>
<td align="right"><img src="logo.png" alt="Checkstyle Logo"/></td>
</tr>
</table>
<!-- content -->
<h2>Overview</h2>
<p class="body">
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>
<pre class="body">
&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;
</pre>
<p class="body">
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>
<h2>Modules</h2>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<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</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>
<h2>Notes</h2>
<ul class="body">
<li>
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
<pre class="body">
&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;
</pre>
</li>
<li>
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:
<pre class="body">
&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;
</pre>
</li>
<li>
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:
<pre class="body">
&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;
</pre>
</li>
<li>Module <span class="code">MemberName</span> also has the
following properties:
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<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>
</li>
</ul>
<hr />
<div><a href="index.html">Back to the Checkstyle Home Page</a></div>
<p class="copyright">
Copyright &copy; 2002-2004 Oliver Burn. All rights Reserved.
</p>
</body>
</html>

View File

@ -1,57 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Reporting Configuration</title>
<link rel="stylesheet" type="text/css" href="mystyle.css" />
</head>
<body>
<h1>Reporting Configuration</h1>
<h2>Caching Support</h2>
<p>The property <span class="code">checkstyle.cache.file</span> specifies the
name of a file that can be used to cache details of files that pass
Checkstyle. This can <i>significantly</i> increase the speed of checkstyle on
successive runs. The property type is
<a href="property_types.html#string">string</a> and defaults to an empty string
(which means do not cache).</p>
<h2>Localisation Support</h2>
<p>Checkstyle supports a mechanism for localising the output messages. If your
language is not supported, please consider translating the messages in the
<span class="default">messages.properties</span> file. Please let us know if
you translate the file.</p>
<p>The property <span class="code">checkstyle.locale.language</span> specifies
the language to use in localising the output messages. The property type is
<a href="property_types.html#string">string</a> and defaults to the default
system locale language.</p>
<p>The property <span class="code">checkstyle.locale.country</span> specifies
the country to use in localising the output messages. The property type is
<a href="property_types.html#string">string</a> and defaults to the default
system locale country.</p>
<h2>Base directory support</h2>
<p>The property <span class="code">checkstyle.basedir</span> specifies a base
directory which files are then reported relative to. For example, if a base
directory is specified as <span class="code">c:\projects\checkstyle</span>,
then an error in the file <span
class="code">c:\projects\checkstyle\src\dir\subdir\File.java</span> will be
reported as <span class="code">src\dir\subdir\File.java</span>. The property
type is <a href="property_types.html#string">string</a> and defaults to an
empty string.</p>
<hr/>
<p class="copyright">Copyright &copy; 2002-2004 Oliver Burn. All rights Reserved.</p>
</body>
</html>

View File

@ -1,455 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Checks for Size Violations</title>
<link rel="stylesheet" type="text/css" href="mystyle.css"/>
</head>
<body>
<!-- The header -->
<table border="0" width="100%" summary="header layout">
<tr>
<td><h1>Checks for Size Violations</h1></td>
<td align="right"><img src="logo.png" alt="Checkstyle Logo"/></td>
</tr>
</table>
<!-- content -->
<table border="0" width="100%" cellpadding="5" summary="body layout">
<tr>
<!--Left menu-->
<td class="menu" valign="top">
<ul>
<li>
<a href="#ExecutableStatementCount">ExecutableStatementCount</a>
</li>
<li>
<a href="#FileLength">FileLength</a>
</li>
<li>
<a href="#LineLength">LineLength</a>
</li>
<li>
<a href="#MethodLength">MethodLength</a>
</li>
<li>
<a href="#AnonInnerLength">AnonInnerLength</a>
</li>
<li>
<a href="#ParameterNumber">ParameterNumber</a>
</li>
</ul>
</td>
<!--Content-->
<td class="content" valign="top" align="left">
<!-- --><a name="ExecutableStatementCount"></a> <h2>ExecutableStatementCount</h2>
<h4>Description</h4>
<p class="body">
Restricts the number of executable statements to a specified limit.
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>max</td>
<td>the maximum threshold allowed</td>
<td><a href="property_types.html#integer">integer</a></td>
<td><span class="default">30</span></td>
</tr>
<tr>
<td>tokens</td>
<td>members to check</td>
<td>subset of tokens <a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CTOR_DEF">CTOR_DEF</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#METHOD_DEF">METHOD_DEF</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#INSTANCE_INIT">INSTANCE_INIT</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#STATIC_INIT">STATIC_INIT</a>
</td>
<td>all tokens</td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;ExecutableStatementCount&quot;/&gt;
</pre>
<p class="body">
To configure the check with a threshold of 20 for constructor and
method definitions:
</p>
<pre class="body">
&lt;module name=&quot;ExecutableStatementCount&quot;&gt;
&lt;property name=&quot;max&quot; value=&quot;20&quot;/&gt;
&lt;property name=&quot;tokens&quot; value=&quot;CTOR_DEF,METHOD_DEF&quot;/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.sizes
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<a name="FileLength"></a> <h2>FileLength</h2> <h4>Description</h4>
<p class="body">
Checks for long source files.
</p>
<p class="body">
Rationale: If a source file becomes very long it is hard to understand.
Therefore long classes should usually be refactored into several individual
classes that focus on a specific task.
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>max</td>
<td>maximum allowable number of lines</td>
<td><a href="property_types.html#integer">integer</a></td>
<td>2000</td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check to accept files with up to 1500 lines:
</p>
<pre class="body">
&lt;module name="FileLength"&gt;
&lt;property name="max" value="1500"/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.sizes
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<a name="LineLength"></a> <h2>LineLength</h2> <h4>Description</h4>
<p class="body">
Checks for long lines.
</p>
<p class="body">
Rationale: Long lines are hard to read in printouts or if developers have
limited screen space for the source code, e.g. if the IDE displays additional
information like project tree, class hierarchy, etc.
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>ignorePattern</td>
<td>pattern for lines to ignore</td>
<td><a href="property_types.html#regexp">regular expression</a></td>
<td>^$</td>
</tr>
<tr>
<td>max</td>
<td>maximum allowable line length</td>
<td><a href="property_types.html#integer">integer</a></td>
<td>80</td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check to accept lines up to 120 characters long:
</p>
<pre class="body">
&lt;module name="LineLength"&gt;
&lt;property name="max" value="120"/&gt;
&lt;/module&gt;
</pre>
<p class="body">
To configure the check to ignore lines that begin with &quot; * &quot;, followed
by just one word, such as within a Javadoc comment:
</p>
<pre class="body">
&lt;module name="LineLength"&gt;
&lt;property name="ignorePattern" value="^ *\* *[^ ]+$"/&gt;
&lt;/module&gt;
</pre>
<h4>Notes</h4>
<ul class="body">
<li>
The calculation of the length of a line takes into account the number of expanded spaces
for a tab character (<span class="code">'\t'</span>). The default number of spaces is
<span class="code">8</span>.
To specify a different number of spaces, the user can
set <a href="config.html#treewalker"><span class="code">TreeWalker</span></a> property
<span class="code">tabWidth</span> which applies to all Checks, including
<span class="code">LineLength</span>; or can set property
<span class="code">tabWidth</span> for <span class="code">LineLength</span> alone.
</li>
<li>Support for the special handling of imports in CheckStyle Version 2 has been
dropped as it is a special case of regexp: The user can set property
<span class="code">ignorePattern</span> to
<span class="code">^import</span> and achieve the same effect.
</li>
</ul>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.sizes
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<a name="MethodLength"></a> <h2>MethodLength</h2> <h4>Description</h4>
<p class="body">
Checks for long methods and constructors.
</p>
<p class="body">
Rationale: If a method becomes very long it is hard to understand. Therefore
long methods should usually be refactored into several individual methods that
focus on a specific task.
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>max</td>
<td>maximum allowable number of lines</td>
<td><a href="property_types.html#integer">integer</a></td>
<td>150</td>
</tr>
<tr>
<td>countEmpty</td>
<td>whether to count empty lines and single line comments of the form <span class="code">//</span></td>
<td><a href="property_types.html#boolean">boolean</a></td>
<td><span class="default">true</span></td>
</tr>
<tr>
<td>tokens</td>
<td>blocks to check</td>
<td>subset of tokens <a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#METHOD_DEF">METHOD_DEF</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CTOR_DEF">CTOR_DEF</a></td>
<td><a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#METHOD_DEF">METHOD_DEF</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CTOR_DEF">CTOR_DEF</a></td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name="MethodLength"/&gt;
</pre>
<p class="body">
To configure the check so that it accepts methods with at most 60 lines:
</p>
<pre class="body">
&lt;module name="MethodLength"&gt;
&lt;property name="tokens" value="METHOD_DEF"/&gt;
&lt;property name="max" value="60"/&gt;
&lt;/module&gt;
</pre>
<p class="body">
To configure the check so that it accepts methods with at most 60 lines, not counting
empty lines and single line comments:
</p>
<pre class="body">
&lt;module name="MethodLength"&gt;
&lt;property name="tokens" value="METHOD_DEF"/&gt;
&lt;property name="max" value="60"/&gt;
&lt;property name="countEmpty" value="false"/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.sizes
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<a name="AnonInnerLength"></a> <h2>AnonInnerLength</h2> <h4>Description</h4>
<p class="body">
Checks for long anonymous inner classes.
</p>
<p class="body">
Rationale: If an anonymous inner class becomes very long
it is hard to understand and to see the flow of the method
where the class is defined. Therefore long anonymous inner
classes should usually be refactored into a named inner class.
See also Bloch, Effective Java, p. 93.
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>max</td>
<td>maximum allowable number of lines</td>
<td><a href="property_types.html#integer">integer</a></td>
<td>20</td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check to accept files with up to 60 lines:
</p>
<pre class="body">
&lt;module name="AnonInnerLength"&gt;
&lt;property name="max" value="60"/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.sizes
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<a name="ParameterNumber"></a> <h2>ParameterNumber</h2> <h4>Description</h4>
<p class="body">
Checks the number of parameters of a method or constructor.
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>max</td>
<td>maximum allowable number of parameters</td>
<td><a href="property_types.html#integer">integer</a></td>
<td>7</td>
</tr>
<tr>
<td>tokens</td>
<td>declarations to check</td>
<td>subset of tokens <a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#METHOD_DEF">METHOD_DEF</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CTOR_DEF">CTOR_DEF</a></td>
<td><a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#METHOD_DEF">METHOD_DEF</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CTOR_DEF">CTOR_DEF</a></td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name="ParameterNumber"/&gt;
</pre>
<p class="body">
To configure the check to allow 10 parameters for a method:
</p>
<pre class="body">
&lt;module name="ParameterNumber"&gt;
&lt;property name="max" value="10"/&gt;
&lt;property name="tokens" value="METHOD_DEF"/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.sizes
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
</td>
</tr>
</table>
<hr />
<div><a href="index.html">Back to the Checkstyle Home Page</a></div>
<p class="copyright">
Copyright &copy; 2002-2004 Oliver Burn. All rights Reserved.
</p>
</body>
</html>

View File

@ -1,328 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Checks for usage</title>
<link rel="stylesheet" type="text/css" href="mystyle.css"/>
</head>
<body>
<!-- The header -->
<table border="0" width="100%" summary="header layout">
<tr>
<td><h1>Checks for usage</h1></td>
<td align="right"><img src="logo.png" alt="Checkstyle Logo"/></td>
</tr>
</table>
<!-- content -->
<table border="0" width="100%" cellpadding="5" summary="body layout">
<tr>
<!--Left menu-->
<td class="menu" valign="top">
<ul>
<li>
<a href="#OneMethodPrivateField">OneMethodPrivateField</a>
</li>
<li>
<a href="#UnusedLocalVariable">UnusedLocalVariable</a>
</li>
<li>
<a href="#UnusedParameter">UnusedParameter</a>
</li>
<li>
<a href="#UnusedPrivateField">UnusedPrivateField</a>
</li>
<li>
<a href="#UnusedPrivateMethod">UnusedPrivateMethod</a>
</li>
</ul>
</td>
<!--Content-->
<td class="content" valign="top" align="left">
<a name="OneMethodPrivateField"></a> <h2>OneMethodPrivateField</h2> <h4>Description</h4>
<p class="body">
Checks that a private field is used in more than one method, constructor, or initializer.
</p>
<p class="body">
Rationale: a private field used in only one method, constructor, or
initializer should be replaced by a local variable.
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>ignoreFormat</td>
<td>pattern for field names that should be ignored</td>
<td><a href="property_types.html#regexp">regular expression</a></td>
<td><span class="default">^$</span> (empty)</td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;usage.OneMethodPrivateField&quot;/&gt;
</pre>
<p class="body">
To configure the check to ignore fields whose name ends in <span class="code">Temp</span>:
</p>
<pre class="body">
&lt;module name=&quot;usage.OneMethodPrivateField&quot;&gt;
&lt;property name=&quot;ignoreFormat&quot; value=&quot;Temp$&quot;/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.usage
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<a name="UnusedLocalVariable"></a> <h2>UnusedLocalVariable</h2> <h4>Description</h4>
<p class="body">
Checks that a local variable is used after its declaration.
</p>
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>ignoreFormat</td>
<td>pattern for variable names that should be ignored</td>
<td><a href="property_types.html#regexp">regular expression</a></td>
<td><span class="default">^$</span> (empty)</td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;usage.UnusedLocalVariable&quot;/&gt;
</pre>
<p class="body">
To configure the check to ignore variables whose name ends in <span class="code">Temp</span>:
</p>
<pre class="body">
&lt;module name=&quot;usage.UnusedLocalVariable&quot;&gt;
&lt;property name=&quot;ignoreFormat&quot; value=&quot;Temp$&quot;/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.usage
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<a name="UnusedParameter"></a> <h2>UnusedParameter</h2> <h4>Description</h4>
<p class="body">
Checks that a parameter is used.
</p>
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>ignoreFormat</td>
<td>pattern for parameter names that should be ignored</td>
<td><a href="property_types.html#regexp">regular expression</a></td>
<td><span class="default">^$</span> (empty)</td>
</tr>
<tr>
<td>ignoreCatch</td>
<td>controls whether <span class="code">catch</span> parameters should be ignored</td>
<td><a href="property_types.html#boolean">boolean</a></td>
<td><span class="default">true</span></td>
</tr>
<tr>
<td>ignoreNonLocal</td>
<td>controls whether parameters of non local (<span
class="code">public, protected or package</span>) methods
should be ignored</td>
<td><a href="property_types.html#boolean">boolean</a></td>
<td><span class="default">false</span></td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;usage.UnusedParameter&quot;/&gt;
</pre>
<p class="body">
To configure the check to ignore parameters whose name ends in <span class="code">Temp</span>:
</p>
<pre class="body">
&lt;module name=&quot;usage.UnusedParameter&quot;&gt;
&lt;property name=&quot;ignoreFormat&quot; value=&quot;Temp$&quot;/&gt;
&lt;/module&gt;
</pre>
<p class="body">
To configure the check to report unused <span class="code">catch</span> parameters:
</p>
<pre class="body">
&lt;module name=&quot;usage.UnusedParameter&quot;&gt;
&lt;property name=&quot;ignoreCatch&quot; value=&quot;false&quot;/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.usage
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<a name="UnusedPrivateField"></a> <h2>UnusedPrivateField</h2> <h4>Description</h4>
<p class="body">
Checks that a private field is used.
</p>
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>ignoreFormat</td>
<td>pattern for field names that should be ignored</td>
<td><a href="property_types.html#regexp">regular expression</a></td>
<td><span class="default">^$</span> (empty)</td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;usage.UnusedPrivateField&quot;/&gt;
</pre>
<p class="body">
To configure the check to ignore fields whose name ends in <span class="code">Temp</span>:
</p>
<pre class="body">
&lt;module name=&quot;usage.UnusedPrivateField&quot;&gt;
&lt;property name=&quot;ignoreFormat&quot; value=&quot;Temp$&quot;/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.usage
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<a name="UnusedPrivateMethod"></a> <h2>UnusedPrivateMethod</h2> <h4>Description</h4>
<p class="body">
Checks that a private method is used.
</p>
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>ignoreFormat</td>
<td>pattern for method names that should be ignored</td>
<td><a href="property_types.html#regexp">regular expression</a></td>
<td><span class="default">^$</span> (empty)</td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;usage.UnusedPrivateMethod&quot;/&gt;
</pre>
<p class="body">
To configure the check to ignore methods whose name ends in <span class="code">Temp</span>:
</p>
<pre class="body">
&lt;module name=&quot;usage.UnusedPrivateMethod&quot;&gt;
&lt;property name=&quot;ignoreFormat&quot; value=&quot;Temp$&quot;/&gt;
&lt;/module&gt;
</pre>
<h4>Notes</h4>
<ul class="body">
<li>The classpath may need to be configured to locate parameter type information. The
classpath configuration is dependent on the mechanism used to invoke Checkstyle.
</li>
</ul>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.usage
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
</td>
</tr>
</table>
<hr />
<div><a href="index.html">Back to the Checkstyle Home Page</a></div>
<p class="copyright">
Copyright &copy; 2002-2004 Oliver Burn. All rights Reserved.
</p>
</body>
</html>

View File

@ -1,980 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Checks for whitespace</title>
<link rel="stylesheet" type="text/css" href="mystyle.css"/>
</head>
<body>
<!-- The header -->
<table border="0" width="100%" summary="header layout">
<tr>
<td><h1>Checks for whitespace</h1></td>
<td align="right"><img src="logo.png" alt="Checkstyle Logo"/></td>
</tr>
</table>
<!-- content -->
<table border="0" width="100%" cellpadding="5" summary="body layout">
<tr>
<!--Left menu-->
<td class="menu" valign="top">
<ul>
<li>
<a href="#EmptyForInitializerPad">EmptyForInitializerPad</a>
</li>
<li>
<a href="#EmptyForIteratorPad">EmptyForIteratorPad</a>
</li>
<li>
<a href="#MethodParamPad">MethodParamPad</a>
</li>
<li>
<a href="#NoWhitespaceAfter">NoWhitespaceAfter</a>
</li>
<li>
<a href="#NoWhitespaceBefore">NoWhitespaceBefore</a>
</li>
<li>
<a href="#OperatorWrap">OperatorWrap</a>
</li>
<li>
<a href="#ParenPad">ParenPad</a>
</li>
<li>
<a href="#TypecastParenPad">TypecastParenPad</a>
</li>
<li>
<a href="#TabCharacter">TabCharacter</a>
</li>
<li>
<a href="#WhitespaceAfter">WhitespaceAfter</a>
</li>
<li>
<a href="#WhitespaceAround">WhitespaceAround</a>
</li>
</ul>
</td>
<!--Content-->
<td class="content" valign="top" align="left">
<a name="EmptyForInitializerPad"></a> <h2>EmptyForInitializerPad</h2> <h4>Description</h4>
<p class="body">
Checks the padding of an empty for initializer; that is whether white
space is required at an empty for initializer, or such white space is
forbidden.
No check occurs if there is a line wrap at the initializer, as in
</p>
<pre class="body">
for (
; i < j; i++, j--)
</pre>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>option</td>
<td>policy on how to pad an empty for iterator</td>
<td><a href="property_types.html#parenPad">pad policy</a></td>
<td><span class="default">nospace</span></td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;EmptyForInitializerPad&quot;/&gt;
</pre>
<p class="body">
To configure the check to require white space at an empty for iterator:
</p>
<pre class="body">
&lt;module name=&quot;EmptyForInitializerPad&quot;&gt;
&lt;property name=&quot;option&quot; value=&quot;space&quot;/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.whitespace
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<a name="EmptyForIteratorPad"></a> <h2>EmptyForIteratorPad</h2> <h4>Description</h4>
<p class="body">
Checks the padding of an empty for iterator; that is whether white
space is required at an empty for iterator, or such white space is
forbidden.
No check occurs if there is a line wrap at the iterator, as in
</p>
<pre class="body">
for (Iterator foo = very.long.line.iterator();
foo.hasNext();
)
</pre>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>option</td>
<td>policy on how to pad an empty for iterator</td>
<td><a href="property_types.html#parenPad">pad policy</a></td>
<td><span class="default">nospace</span></td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;EmptyForIteratorPad&quot;/&gt;
</pre>
<p class="body">
To configure the check to require white space at an empty for iterator:
</p>
<pre class="body">
&lt;module name=&quot;EmptyForIteratorPad&quot;&gt;
&lt;property name=&quot;option&quot; value=&quot;space&quot;/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.whitespace
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<a name="MethodParamPad"></a> <h2>MethodParamPad</h2>
<h4>Description</h4>
<p class="body">
Checks the padding between the identifier of a method definition,
constructor definition, method call, or constructor invocation;
and the left parenthesis of the parameter list.
That is, if the identifier and left parenthesis are on the same line,
checks whether a space is required immediately after the identifier or
such a space is forbidden.
If they are not on the same line, reports an error, unless configured to allow line breaks.
To allow linebreaks after the identifier,
set property <span class="code">allowLineBreaks</span> to <span class="code">
true</span>.
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>allowLineBreaks</td>
<td>whether a line break between the identifier and left parenthesis
is allowed</td>
<td><a href="property_types.html#boolean">boolean</a></td>
<td><span class="default">false</span></td>
</tr>
<tr>
<td>tokens</td>
<td>tokens to check</td>
<td>subset of tokens <a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CTOR_DEF">CTOR_DEF</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_NEW">LITERAL_NEW</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#METHOD_CALL">METHOD_CALL</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#METHOD_DEF">METHOD_DEF</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#SUPER_CTOR_CALL">SUPER_CTOR_CALL</a>
</td>
<td><a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CTOR_DEF">CTOR_DEF</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_NEW">LITERAL_NEW</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#METHOD_CALL">METHOD_CALL</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#METHOD_DEF">METHOD_DEF</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#SUPER_CTOR_CALL">SUPER_CTOR_CALL</a>
</td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;MethodParamPad&quot;/&gt;
</pre>
<p class="body">
To configure the check to require a space
after the identifier of a method definition, except if the left
parenthesis occurs on a new line:
</p>
<pre class="body">
&lt;module name=&quot;MethodParamPad&quot;&gt;
&lt;property name=&quot;tokens&quot; value=&quot;METHOD_DEF&quot;/&gt;
&lt;property name=&quot;option&quot; value=&quot;space&quot;/&gt;
&lt;property name=&quot;allowLineBreaks&quot; value=&quot;true&quot;/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.whitespace
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<a name="NoWhitespaceAfter"></a> <h2>NoWhitespaceAfter</h2>
<h4>Description</h4>
<p class="body">
Checks that there is no whitespace after a token. More specifically, it checks
that it is not followed by whitespace, or (if linebreaks are allowed) all
characters on the line after are whitespace. To forbid linebreaks after a token,
set property <span class="code">allowLineBreaks</span> to <span class="code">
false</span>.
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>allowLineBreaks</td>
<td>whether whitespace is allowed if the token is at a linebreak</td>
<td><a href="property_types.html#boolean">boolean</a></td>
<td><span class="default">true</span></td>
</tr>
<tr>
<td>tokens</td>
<td>tokens to check</td>
<td>subset of tokens <a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#ARRAY_INIT">ARRAY_INIT</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#BNOT">BNOT</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#DEC">DEC</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#DOT">DOT</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#INC">INC</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LNOT">LNOT</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#UNARY_MINUS">UNARY_MINUS</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#UNARY_PLUS">UNARY_PLUS</a></td>
<td><a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#ARRAY_INIT">ARRAY_INIT</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#BNOT">BNOT</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#DEC">DEC</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#DOT">DOT</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#INC">INC</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LNOT">LNOT</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#UNARY_MINUS">UNARY_MINUS</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#UNARY_PLUS">UNARY_PLUS</a></td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;NoWhitespaceAfter&quot;/&gt;
</pre>
<p class="body">
To configure the check to forbid linebreaks after a DOT token:
</p>
<pre class="body">
&lt;module name=&quot;NoWhitespaceAfter&quot;&gt;
&lt;property name=&quot;tokens&quot; value=&quot;DOT&quot;/&gt;
&lt;property name=&quot;allowLineBreaks&quot; value=&quot;false&quot;/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.whitespace
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<a name="NoWhitespaceBefore"></a> <h2>NoWhitespaceBefore</h2> <h4>Description</h4>
<p class="body">
Checks that there is no whitespace before a token. More specifically, it checks
that it is not preceded with whitespace, or (if linebreaks are allowed) all
characters on the line before are whitespace. To allow linebreaks before a token,
set property <span class="code">allowLineBreaks</span> to <span class="code">
true</span>.
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>allowLineBreaks</td>
<td>whether whitespace is allowed if the token is at a linebreak</td>
<td><a href="property_types.html#boolean">boolean</a></td>
<td><span class="default">false</span></td>
</tr>
<tr>
<td>tokens</td>
<td>tokens to check</td>
<td>subset of tokens <a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#SEMI">SEMI</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#DOT">DOT</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#POST_DEC">POST_DEC</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#POST_INC">POST_INC</a></td>
<td><a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#SEMI">SEMI</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#POST_DEC">POST_DEC</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#POST_INC">POST_INC</a></td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;NoWhitespaceBefore&quot;/&gt;
</pre>
<p class="body">
To configure the check to allow linebreaks before a DOT token:
</p>
<pre class="body">
&lt;module name=&quot;NoWhitespaceBefore&quot;&gt;
&lt;property name=&quot;tokens&quot; value=&quot;DOT&quot;/&gt;
&lt;property name=&quot;allowLineBreaks&quot; value=&quot;true&quot;/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.whitespace
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<a name="OperatorWrap"></a> <h2>OperatorWrap</h2> <h4>Description</h4>
<p class="body">
Checks the policy on how to wrap lines on operators.
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>option</td>
<td>policy on how to wrap lines</td>
<td><a href="property_types.html#wrapOp">wrap operator policy</a></td>
<td><span class="default">nl</span></td>
</tr>
<tr>
<td>tokens</td>
<td>tokens to check</td>
<td>subset of tokens <a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#ASSIGN">ASSIGN</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#BAND">BAND</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#BAND_ASSIGN">BAND_ASSIGN</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#BOR">BOR</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#BOR_ASSIGN">BOR_ASSIGN</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#BSR">BSR</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#BSR_ASSIGN">BSR_ASSIGN</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#BXOR">BXOR</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#BXOR_ASSIGN">BXOR_ASSIGN</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#COLON">COLON</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#DIV">DIV</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#DIV_ASSIGN">DIV_ASSIGN</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#EQUAL">EQUAL</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#GE">GE</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#GT">GT</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LAND">LAND</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LE">LE</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_INSTANCEOF">LITERAL_INSTANCEOF</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LOR">LOR</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LT">LT</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#MINUS">MINUS</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#MINUS_ASSIGN">MINUS_ASSIGN</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#MOD">MOD</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#MOD_ASSIGN">MOD_ASSIGN</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#NOT_EQUAL">NOT_EQUAL</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#PLUS">PLUS</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#PLUS_ASSIGN">PLUS_ASSIGN</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#QUESTION">QUESTION</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#SL">SL</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#SL_ASSIGN">SL_ASSIGN</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#SR">SR</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#SR_ASSIGN">SR_ASSIGN</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#STAR">STAR</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#STAR_ASSIGN">STAR_ASSIGN</a></td>
<td><a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#BAND">BAND</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#BOR">BOR</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#BSR">BSR</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#BXOR">BXOR</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#COLON">COLON</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#DIV">DIV</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#EQUAL">EQUAL</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#GE">GE</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#GT">GT</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LAND">LAND</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LE">LE</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_INSTANCEOF">LITERAL_INSTANCEOF</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LOR">LOR</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LT">LT</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#MINUS">MINUS</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#MOD">MOD</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#NOT_EQUAL">NOT_EQUAL</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#PLUS">PLUS</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#QUESTION">QUESTION</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#SL">SL</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#SR">SR</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#STAR">STAR</a>
(all tokens except assignment operators)</td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;OperatorWrap&quot;/&gt;
</pre>
<p class="body">
To configure the check for the assignment operator, <span class="code">=</span>,
at the end of a line:
</p>
<pre class="body">
&lt;module name=&quot;OperatorWrap&quot;&gt;
&lt;property name=&quot;tokens&quot; value=&quot;ASSIGN&quot;/&gt;
&lt;property name=&quot;option&quot; value=&quot;eol&quot;/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.whitespace
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<a name="ParenPad"></a> <h2>ParenPad</h2> <h4>Description</h4>
<p class="body">
Checks the policy on the padding of parentheses; i.e. whether a space is
required after a left parenthesis and before a right parenthesis, or such spaces
are forbidden.
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>option</td>
<td>policy on how to pad parentheses</td>
<td><a href="property_types.html#parenPad">pad policy</a></td>
<td><span class="default">nospace</span></td>
</tr>
<tr>
<td>tokens</td>
<td>tokens to check</td>
<td>subset of tokens <a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CTOR_CALL">CTOR_CALL</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LPAREN">LPAREN</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#METHOD_CALL">METHOD_CALL</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#RPAREN">RPAREN</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#SUPER_CTOR_CALL">SUPER_CTOR_CALL</a>
<td><a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CTOR_CALL">CTOR_CALL</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LPAREN">LPAREN</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#METHOD_CALL">METHOD_CALL</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#RPAREN">RPAREN</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#SUPER_CTOR_CALL">SUPER_CTOR_CALL</a>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;ParenPad&quot;/&gt;
</pre>
<p class="body">
To configure the check to require spaces for the parentheses of constructor,
method, and super constructor calls:
</p>
<pre class="body">
&lt;module name=&quot;ParenPad&quot;&gt;
&lt;property name=&quot;tokens&quot; value=&quot;CTOR_CALL, METHOD_CALL,
SUPER_CTOR_CALL&quot;/&gt;
&lt;property name=&quot;option&quot; value=&quot;space&quot;/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.whitespace
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<a name="TypecastParenPad"></a>
<h2>TypecastParenPad</h2>
<h4>Description</h4>
<p class="body"> Checks the policy on the padding of parentheses for
typecasts. That is, whether a space is required after a left parenthesis
and before a right parenthesis, or such spaces are forbidden. </p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>option</td>
<td>policy on how to pad parentheses</td>
<td><a href="property_types.html#parenPad">pad policy</a></td>
<td><span class="default">nospace</span></td>
</tr>
<tr>
<td>tokens</td>
<td>tokens to check</td>
<td>Must have tokens
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#TYPECAST">TYPECAST</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#RPAREN">RPAREN</a>
<td><a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#TYPECAST">TYPECAST</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#RPAREN">RPAREN</a>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;TypecastParenPad&quot;/&gt;
</pre>
<p class="body">
To configure the check to require spaces:
</p>
<pre class="body">
&lt;module name=&quot;TypecastParenPad&quot;&gt;
&lt;property name=&quot;option&quot; value=&quot;space&quot;/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.whitespace
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<a name="TabCharacter"></a> <h2>TabCharacter</h2> <h4>Description</h4>
<p class="body">
Checks that there are no tab characters (<span class="code">'\t'</span>) in the
source code.
</p>
<p class="body">
Rationale:
</p>
<ul class="body">
<li>
Developers should not need to configure the tab width of their text editors in
order to be able to read source code.
</li>
<li>
From the Apache jakarta coding standards: In a distributed development
environment, when the cvs commit messages get sent to a mailing list, they are
almost impossible to read if you use tabs.
</li>
</ul>
<h4>Example</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;TabCharacter&quot;/&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.whitespace
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<a name="WhitespaceAfter"></a> <h2>WhitespaceAfter</h2> <h4>Description</h4>
<p class="body">
Checks that a token is followed by whitespace.
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>tokens</td>
<td>tokens to check</td>
<td>subset of tokens <a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#COMMA">COMMA</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#SEMI">SEMI</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#TYPECAST">TYPECAST</a></td>
<td><a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#COMMA">COMMA</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#SEMI">SEMI</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#TYPECAST">TYPECAST</a></td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;WhitespaceAfter&quot;/&gt;
</pre>
<p class="body">
To configure the check for whitespace only after COMMA and SEMI tokens:
</p>
<pre class="body">
&lt;module name=&quot;WhitespaceAfter&quot;&gt;
&lt;property name=&quot;tokens&quot; value=&quot;COMMA, SEMI&quot;/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.whitespace
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<a name="WhitespaceAround"></a> <h2>WhitespaceAround</h2> <h4>Description</h4>
<p class="body">
Checks that a token is surrounded by whitespace.
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>tokens</td>
<td>tokens to check</td>
<td>subset of tokens <a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#ASSIGN">ASSIGN</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#BAND">BAND</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#BAND_ASSIGN">BAND_ASSIGN</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#BOR">BOR</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#BOR_ASSIGN">BOR_ASSIGN</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#BSR">BSR</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#BSR_ASSIGN">BSR_ASSIGN</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#BXOR">BXOR</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#BXOR_ASSIGN">BXOR_ASSIGN</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#COLON">COLON</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#DIV">DIV</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#DIV_ASSIGN">DIV_ASSIGN</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#EQUAL">EQUAL</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#GE">GE</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#GT">GT</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LAND">LAND</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LCURLY">LCURLY</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LE">LE</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_ASSERT">LITERAL_ASSERT</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_CATCH">LITERAL_CATCH</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_DO">LITERAL_DO</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_ELSE">LITERAL_ELSE</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_FINALLY">LITERAL_FINALLY</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_FOR">LITERAL_FOR</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_IF">LITERAL_IF</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_RETURN">LITERAL_RETURN</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_SYNCHRONIZED">LITERAL_SYNCHRONIZED</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_TRY">LITERAL_TRY</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_WHILE">LITERAL_WHILE</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LOR">LOR</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LT">LT</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#MINUS">MINUS</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#MINUS_ASSIGN">MINUS_ASSIGN</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#MOD">MOD</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#MOD_ASSIGN">MOD_ASSIGN</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#NOT_EQUAL">NOT_EQUAL</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#PLUS">PLUS</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#PLUS_ASSIGN">PLUS_ASSIGN</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#QUESTION">QUESTION</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#RCURLY">RCURLY</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#SL">SL</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#SLIST">SLIST</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#SL_ASSIGN">SL_ASSIGN</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#SR">SR</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#SR_ASSIGN">SR_ASSIGN</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#STAR">STAR</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#STAR_ASSIGN">STAR_ASSIGN</a></td>
<td>all tokens</td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;WhitespaceAround&quot;/&gt;
</pre>
<p class="body">
To configure the check for whitespace around the assignment operator, <span class="code">=</span>:
</p>
<pre class="body">
&lt;module name=&quot;WhitespaceAround&quot;&gt;
&lt;property name=&quot;tokens&quot; value=&quot;ASSIGN&quot;/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.whitespace
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
</td>
</tr>
</table>
<hr />
<div><a href="index.html">Back to the Checkstyle Home Page</a></div>
<p class="copyright">
Copyright &copy; 2002-2004 Oliver Burn. All rights Reserved.
</p>
</body>
</html>

View File

@ -1,136 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Contributing to Checkstyle</title>
<link rel="stylesheet" type="text/css" href="mystyle.css"/>
</head>
<body>
<!-- The header -->
<table border="0" width="100%" summary="header layout">
<tr>
<td>
<h1>Contributing to Checkstyle</h1>
</td>
<td align="right">
<img src="logo.png" alt="Checkstyle Logo"/>
</td>
</tr>
</table>
<!-- content -->
<table border="0" width="100%" cellpadding="5" summary="body layout">
<tr>
<!--Left menu-->
<td class="menu" valign="top">
<p>Contributing</p>
<ul>
<li><a href="#intro">Introduction</a></li>
<li><a href="#quality">Quality</a></li>
<li><a href="#submit">Submitting</a></li>
</ul>
</td>
<!--Content-->
<td class="content" valign="top" align="left">
<a name="intro"></a>
<h2>Introduction</h2>
<p class="body">
Hey, good to see you on this page. It means that you are
considering a contribution of your own work to the Checkstyle
project. We welcome anything: bugfixes, new check modules, unit
tests, documentation improvements, build process simplification,
etc.
</p>
<p class="body">
This document assumes you are working with the CVS version of
checkstyle and that you are familiar with some standard
development tools (<a href="http://www.cvshome.org">CVS</a>,
<a href="http://ant.apache.org">Ant</a>, <a
href="http://www.junit.org">JUnit</a>).
</p>
<a name="quality"></a>
<h2>Quality matters</h2>
<p class="body">
The developer team of checkstyle is really a lazy bunch of
people. We try to avoid work as best as we can, but most of all
we try to avoid working on bugs that are reported by end users.
</p>
<p class="body">
To that end, we use a set of development tools that ensure that the
quality of our code is kept at a fairly high level. Like most projects
today, we use JUnit to test our code. However we do take this one
step further and measure the coverage of our unit tests using
<a href="http://www.thecortex.net/clover">Clover</a>. This means it
is not sufficient to pass all tests, but the tests should ideally
execute each line in the code. The most recent Clover report is
available <a href="http://checkstyle.sourceforge.net/clover_html/">here</a>.
</p>
<p class="body">
Besides using unit testing, we obviously also use checkstyle to check
it's own code.
</p>
<p class="body">
We have the build target <span class="code">gump</span> in our
Ant buildfile that builds checkstyle, executes all tests,
and runs checkstyle on it's own code.
That target should pass without errors.
</p>
<p class="body">
If you add new end user features, remember to document them.
</p>
<a name="submit"></a>
<h2>Submitting your contribution</h2>
<p class="body">
Once you have made sure that your changes pass the gump target,
and everthing is documented, you are ready to submit your work.
</p>
<p class="body">
If you have created new files, put them in a tgz file (or zip if you
are on Windows). If you have changed existing files, create a unified
diff using CVS. To do that, open a command line, cd to the home
directory of checkstyle (where build.xml is located) and execute
<span class="code">cvs diff -u &gt; mychanges.patch</span>.
</p>
<p class="body">
Create a new item in our
<a href="http://sourceforge.net/tracker/?group_id=29721&amp;atid=397080">patch tracker</a>
and add the tgz/zip/patch files you created.
Make sure the text in the tracker explains the purpose of your contribution.
When you create a tracker entry, a notification email about your contribution
will automatically be sent to the developer mailing list.
Be prepared to answer questions and do some polishing work.
</p>
<p class="body">
We are not only lazy but at times we are also busy with our day jobs.
This means that you might not always get an immediate answer. You are
not being ignored, and we value your work - we might just be too busy
to review your code, especially if it is a bit complex. If you don't
get a response within two weeks, feel free to send a reminder email about
your tracker item.
</p>
</td>
</tr>
</table>
<hr/>
<div><a href="index.html">Back to the Checkstyle Home Page</a></div>
<p class="copyright">Copyright &copy; 2002-2004 Oliver Burn. All rights Reserved.</p>
</body> </html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

View File

@ -1,18 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2004 Oliver Burn
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
////////////////////////////////////////////////////////////////////////////////

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

View File

@ -1,77 +0,0 @@
h1 {
font-family : monospace;
font-size : 28px;
font-weight : bold;
color : #aaaaaa;
background-color: #ffffff;
text-transform: capitalize;
}
h2 {
text-transform: capitalize;
}
h4.tip {
text-transform: capitalize;
text-align: center;
}
td {
vertical-align:top;
}
td.required {
text-align: center;
}
tr.header {
background-color: Silver;
color:Black;
font-weight: bolder;
text-align: center;
}
td.menu {
background-color: #eeeeee;
color:Black;
text-align: left;
white-space: nowrap;
}
td.content {
width: 100%;
}
*.body {
margin-left : 5%;
margin-right : 3%;
}
img {
border: none;
}
p.copyright {
text-align: center;
}
span.code {
white-space: nowrap;
font-family: monospace;
font-weight: bold
}
span.default {
white-space: nowrap;
font-family: monospace;
}
div.tip {
margin-left : 5%;
margin-right : 5%;
padding-left: 2%;
padding-right: 2%;
background-color: Silver;
color:Black;
border: ridge;
}

View File

@ -1,77 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Optional Checks - Version @CHECKSTYLE_VERSION@</title>
<link rel="stylesheet" type="text/css" href="mystyle.css"/>
</head>
<body>
<table border="0" width="100%" summary="header layout">
<tr>
<td>
<h1>Optional Checks - Version @CHECKSTYLE_VERSION@</h1>
</td>
<td align="right">
<img src="logo.png" alt="Checkstyle Logo"/>
</td>
</tr>
</table>
<h2>Overview</h2>
<p>
Core Checkstyle Checks are applicable to general Java coding style and require no
external libraries. An optional Check is for special applications or requires
additional libraries. There are are optional Checks for:
</p>
<ul>
<li><a href="config_j2ee.html">J2EE Requirements</a></li>
<li><a href="config_usage.html">Usage</a></li>
</ul>
<h2>Configuration</h2>
<p>
As with core Checks, optional Checks are configured as submodules of
<a href="http://config.html#treewalker">TreeWalker</a>. The shortened
name of an optional Check module must include the appropriate package
name prefix. For example, this is a configuration fragment
for Check <span class="code">com.puppycrawl.tools.checkstyle.checks.usage.UnusedLocalVariable</span>:
</p>
<pre>
&lt;module name=&quot;usage.UnusedLocalVariable&quot;/&gt;
</pre>
<p>
Consult the <a href="config.html#packagenames">Checkstyle configuration manual</a>
to learn how to integrate
optional Checks into the package configuration so that you can use fully shortened
names such as <span class="code">UnusedLocalVariable</span>.
</p>
<h2>Usage</h2>
<p>
Optional checks are distributed in jar file
<span class="code">checkstyle-optional-@CHECKSTYLE_VERSION@.jar</span> and,
in order to use an optional check, this jar file must be in the classpath.
For example, this is a command to run Checkstyle with a configuration
that contains optional checks:
</p>
<pre>
java -classpath checkstyle-optional-@CHECKSTYLE_VERSION@.jar:checkstyle-all-@CHECKSTYLE_VERSION@.jar \
com.puppycrawl.tools.checkstyle.Main \
-c config.xml -r .
</pre>
<p>
Please consult <a href="cmdline.html">Command Line</a> and
<a href="anttask.html">ANT Task</a> documentation for further usage information.
</p>
<hr />
<div><a href="index.html">Back to the Checkstyle Home Page</a></div>
<p class="copyright">Copyright &copy; 2002-2004 Oliver Burn. All rights Reserved.</p>
</body>
</html>

View File

@ -1,300 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Property Types</title>
<link rel="stylesheet" type="text/css" href="mystyle.css" />
</head>
<body>
<h1>Property Types</h1>
<p>Checkstyle is configured using properties, which are string
representations. This document describes how these string representations are
mapped to typed properties.</p>
<h2><a name="integer">Integer</a></h2>
<p>This property represents an integer. The string representation is parsed
using the <span class="code">java.lang.Integer</span> class.</p>
<h2><a name="string">String</a></h2>
<p>This property represents a string. The literal string representation is
used.</p>
<h2><a name="boolean">Boolean</a></h2>
<p>This property represents a boolean. The default value is <span
class="code">false</span>. The following string representations will map to
<span class="code">true</span>:</p>
<ul>
<li><span class="code">yes</span></li>
<li><span class="code">true</span></li>
<li><span class="code">on</span></li>
</ul>
<p>Anything else will map to <span class="code">false</span>.</p>
<h2><a name="stringSet">String Set</a></h2>
<p>This property represents a set of strings. The string representation is
parsed as a set of comma (',') separated strings.</p>
<h2><a name="intSet">Integer Set</a></h2>
<p>This property represents a set of integers. The string representation is
parsed as a set of comma (',') separated integers that are parsed using the
<span class="code">java.lang.Integer</span> class.</p>
<h2><a name="regexp">Regular Expression</a></h2>
<p>This property represents a regular expression. The string representation is
parsed using the excellent <a href="http://jakarta.apache.org/regexp/">Jakarta
Regexp</a> library.</p>
<h2><a name="parenPad">Pad Policy</a></h2>
<p>This property represents the policy for padding with white space. The
following table describes the valid options:</p>
<table border="1" summary="padding options">
<tr class="header">
<td>Option</td>
<td>Definition</td>
</tr>
<tr>
<td><span class="code">nospace</span></td>
<td>Do not pad. For example, <span class="code">method(a, b);</span></td>
</tr>
<tr>
<td><span class="code">space</span></td>
<td>Ensure padding. For example, <span class="code">method( a, b );</span></td>
</tr>
</table>
<h2><a name="wrapOp">Operator Wrap Policy</a></h2>
<p>This property represents the policy for wrapping lines on operators. The
following table describes the valid options:</p>
<table border="1" summary="wrap operator options">
<tr class="header">
<td>Option</td>
<td>Definition</td>
</tr>
<tr>
<td><span class="code">nl</span></td>
<td>The operator must be on a new line. For example:
<pre>
someVariable = aBigVariableNameToMakeThings + "this may work"
+ lookVeryInteresting;
</pre>
</td>
</tr>
<tr>
<td><span class="code">eol</span></td>
<td>The operator must be at the end of the line. For example:
<pre>
someVariable = aBigVariableNameToMakeThings + "this may work" +
lookVeryInteresting;
</pre>
</td>
</tr>
</table>
<h2><a name="block">Block Policy</a></h2>
<p>This property represents the policy for checking block statements. The
following table describes the valid options:</p>
<table border="1" summary="block options">
<tr class="header">
<td>Option</td>
<td>Definition</td>
</tr>
<tr>
<td><span class="code">text</span></td>
<td>Require that there is some text in the block. For example:
<pre>
catch (Exception ex) {
// This is a bad coding practice
}
</pre>
</td>
</tr>
<tr>
<td><span class="code">stmt</span></td>
<td>Require that there is a statement in the block. For example:
<pre>
finally {
lock.release();
}
</pre>
</td>
</tr>
</table>
<h2><a name="lcurly">left curly brace policy</a></h2>
<p>This property represents the policy for checking the placement of a left
curly brace (<span class="code">'{'</span>). The following table describes the
valid options:</p>
<table border="1" summary="left curly options">
<tr class="header">
<td>Option</td>
<td>Definition</td>
</tr>
<tr>
<td><span class="code">eol</span></td>
<td>The brace must always be on the end of the line. For example:
<pre>
if (condition) {
...
</pre>
</td>
</tr>
<tr>
<td><span class="code">nl</span></td>
<td>The brace must always be on a new line. For example:
<pre>
if (condition)
{
...
</pre>
</td>
</tr>
<tr>
<td><span class="code">nlow</span></td>
<td>If the brace will fit on the first line of the statement, taking into account maximum line length, then apply <span class="code">eol</span> rule. Otherwise apply the <span class="code">nl</span> rule. <span class="code">nlow</span> is a mnemonic for "new line on wrap". For the example above Checkstyle will enforce:
<pre>
if (condition) {
...
</pre>
But for a statement spanning multiple lines, Checkstyle will enforce:
<pre>
if (condition1 &amp;&amp; condition2 &amp;&amp;
condition3 &amp;&amp; condition4)
{
...
</pre>
</td>
</tr>
</table>
<h2><a name="rcurly">right curly brace policy</a></h2>
<p>This property represents the policy for checking the placement of a right
curly brace (<span class="code">'}'</span>). The following table describes the
valid options:</p>
<table border="1" summary="right curly options">
<tr class="header">
<td>Option</td>
<td>Definition</td>
</tr>
<tr>
<td><span class="code">same</span></td>
<td>The brace must be on the same line as the next statement. For example:
<pre>
try {
...
} finally {
</pre>
</td>
</tr>
<tr>
<td><span class="code">alone</span></td>
<td>The brace must be alone on the line. For example:
<pre>
try {
...
}
finally {
</pre>
</td>
</tr>
</table>
<h2><a name="scope">Scope</a></h2>
<p>This property represents a Java scope. The valid options are:</p>
<ul>
<li><span class="default">nothing</span></li>
<li><span class="default">public</span></li>
<li><span class="default">protected</span></li>
<li><span class="default">package</span></li>
<li><span class="default">private</span></li>
<li><span class="default">anoninner</span></li>
</ul>
<h2><a name="severity">Severity</a></h2>
<p>This property represents the severity level of a check violation. The valid options are:</p>
<ul>
<li><span class="default">ignore</span></li>
<li><span class="default">info</span></li>
<li><span class="default">warning</span></li>
<li><span class="default">error</span></li>
</ul>
<h2><a name="persistence">persistence policy</a></h2>
<p>This property represents the policy for checking entity beans according
to whether the beans have bean-managed persistence, container-managed persistence,
or mixed persistence:</p>
<table border="1" summary="right curly options">
<tr class="header">
<td>Option</td>
<td>Definition</td>
</tr>
<tr>
<td><span class="code">bean</span></td>
<td>The beans have bean-managed persistence.</td>
</tr>
<tr>
<td><span class="code">container</span></td>
<td>The beans have container-managed persistence.</td>
</tr>
<tr>
<td><span class="code">mixed</span></td>
<td>The beans have mixed bean-managed and container-managed persistence.</td>
</tr>
</table>
<hr />
<div><a href="index.html">Back to the Checkstyle Home Page</a></div>
<p class="copyright">Copyright &copy; 2002-2004 Oliver Burn. All rights Reserved.</p>
</body>
</html>

View File

@ -1,171 +0,0 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.2//EN"
"http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
<!--
Checkstyle configuration that checks the sun coding conventions from:
- the Java Language Specification at
http://java.sun.com/docs/books/jls/second_edition/html/index.html
- the Sun Code Conventions at http://java.sun.com/docs/codeconv/
- the Javadoc guidelines at
http://java.sun.com/j2se/javadoc/writingdoccomments/index.html
- the JDK Api documentation http://java.sun.com/j2se/docs/api/index.html
- some best practices
Checkstyle is very configurable. Be sure to read the documentation at
http://checkstyle.sf.net (or in your downloaded distribution).
Most Checks are configurable, be sure to consult the documentation.
To completely disable a check, just comment it out or delete it from the file.
Finally, it is worth reading the documentation.
-->
<module name="Checker">
<!-- Checks that a package.html file exists for each package. -->
<!-- See http://checkstyle.sf.net/config_javadoc.html#PackageHtml -->
<module name="PackageHtml"/>
<!-- Checks whether files end with a new line. -->
<!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile -->
<module name="NewlineAtEndOfFile"/>
<!-- Checks that property files contain the same keys. -->
<!-- See http://checkstyle.sf.net/config_misc.html#Translation -->
<module name="Translation"/>
<module name="TreeWalker">
<!-- Checks for Javadoc comments. -->
<!-- See http://checkstyle.sf.net/config_javadoc.html -->
<module name="JavadocMethod"/>
<module name="JavadocType"/>
<module name="JavadocVariable"/>
<module name="JavadocStyle"/>
<!-- Checks for Naming Conventions. -->
<!-- See http://checkstyle.sf.net/config_naming.html -->
<module name="ConstantName"/>
<module name="LocalFinalVariableName"/>
<module name="LocalVariableName"/>
<module name="MemberName"/>
<module name="MethodName"/>
<module name="PackageName"/>
<module name="ParameterName"/>
<module name="StaticVariableName"/>
<module name="TypeName"/>
<!-- Checks for Headers -->
<!-- See http://checkstyle.sf.net/config_header.html -->
<!-- <module name="Header"> -->
<!-- The follow property value demonstrates the ability -->
<!-- to have access to ANT properties. In this case it uses -->
<!-- the ${basedir} property to allow Checkstyle to be run -->
<!-- from any directory within a project. See property -->
<!-- expansion, -->
<!-- http://checkstyle.sf.net/config.html#properties -->
<!-- <property -->
<!-- name="headerFile" -->
<!-- value="${basedir}/java.header"/> -->
<!-- </module> -->
<!-- Following interprets the header file as regular expressions. -->
<!-- <module name="RegexpHeader"/> -->
<!-- Checks for imports -->
<!-- See http://checkstyle.sf.net/config_import.html -->
<module name="AvoidStarImport"/>
<module name="IllegalImport"/> <!-- defaults to sun.* packages -->
<module name="RedundantImport"/>
<module name="UnusedImports"/>
<!-- Checks for Size Violations. -->
<!-- See http://checkstyle.sf.net/config_sizes.html -->
<module name="FileLength"/>
<module name="LineLength"/>
<module name="MethodLength"/>
<module name="ParameterNumber"/>
<!-- Checks for whitespace -->
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
<module name="EmptyForIteratorPad"/>
<module name="MethodParamPad"/>
<module name="NoWhitespaceAfter"/>
<module name="NoWhitespaceBefore"/>
<module name="OperatorWrap"/>
<module name="ParenPad"/>
<module name="TypecastParenPad"/>
<module name="TabCharacter"/>
<module name="WhitespaceAfter"/>
<module name="WhitespaceAround"/>
<!-- Modifier Checks -->
<!-- See http://checkstyle.sf.net/config_modifiers.html -->
<module name="ModifierOrder"/>
<module name="RedundantModifier"/>
<!-- Checks for blocks. You know, those {}'s -->
<!-- See http://checkstyle.sf.net/config_blocks.html -->
<module name="AvoidNestedBlocks"/>
<module name="EmptyBlock"/>
<module name="LeftCurly"/>
<module name="NeedBraces"/>
<module name="RightCurly"/>
<!-- Checks for common coding problems -->
<!-- See http://checkstyle.sf.net/config_coding.html -->
<module name="AvoidInlineConditionals"/>
<module name="DoubleCheckedLocking"/> <!-- MY FAVOURITE -->
<module name="EmptyStatement"/>
<module name="EqualsHashCode"/>
<module name="HiddenField"/>
<module name="IllegalInstantiation"/>
<module name="InnerAssignment"/>
<module name="MagicNumber"/>
<module name="MissingSwitchDefault"/>
<module name="RedundantThrows"/>
<module name="SimplifyBooleanExpression"/>
<module name="SimplifyBooleanReturn"/>
<!-- Checks for class design -->
<!-- See http://checkstyle.sf.net/config_design.html -->
<module name="DesignForExtension"/>
<module name="FinalClass"/>
<module name="HideUtilityClassConstructor"/>
<module name="InterfaceIsType"/>
<module name="VisibilityModifier"/>
<!-- Miscellaneous other checks. -->
<!-- See http://checkstyle.sf.net/config_misc.html -->
<module name="ArrayTypeStyle"/>
<module name="FinalParameters"/>
<module name="GenericIllegalRegexp">
<property name="format" value="\s+$"/>
<property name="message" value="Line has trailing spaces."/>
</module>
<module name="TodoComment"/>
<module name="UpperEll"/>
</module>
</module>

View File

@ -1,14 +0,0 @@
<?xml version="1.0"?>
<!DOCTYPE suppressions PUBLIC
"-//Puppy Crawl//DTD Suppressions 1.0//EN"
"http://www.puppycrawl.com/dtds/suppressions_1_0.dtd">
<suppressions>
<suppress checks="MagicNumberCheck"
files="JavadocStyleCheck.java"
lines="231"/>
<suppress checks="FileLength"
files="TokenTypes.java"
lines="1"/>
</suppressions>

View File

@ -1,592 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Writing your own checks</title>
<link rel="stylesheet" type="text/css" href="mystyle.css"/>
</head>
<body>
<!-- The header -->
<table border="0" width="100%" summary="header layout">
<tr>
<td>
<h1>Writing your own Checks</h1>
</td>
<td align="right">
<img src="logo.png" alt="Checkstyle Logo"/>
</td>
</tr>
</table>
<!-- content -->
<table border="0" width="100%" cellpadding="5" summary="body layout">
<tr>
<!--Left menu-->
<td class="menu" valign="top">
<p><a href="#overview">Overview</a></p>
<p><a href="#checks">Writing Checks</a></p>
<ul>
<li><a href="#grammar">Java Grammar</a></li>
<li><a href="#gui">Checkstyle GUI</a></li>
<li><a href="#visitor">Visitor Pattern</a></li>
<li><a href="#regtokens">Visitor in Action</a></li>
<li><a href="#astnav">Navigating the AST</a></li>
<li><a href="#configchecks">Defining Properties</a></li>
<li><a href="#logerrors">Logging Errors</a></li>
<li><a href="#integrate">Integrating Checks</a></li>
<li><a href="#limitations">Limitations</a></li>
</ul>
<p><a href="#filesetchecks">Writing FileSetChecks</a></p>
<p><a href="#huh">Huh?</a></p>
<p><a href="#contributeback">Contributing</a></p>
</td>
<!--Content-->
<td class="content" valign="top" align="left">
<a name="overview"></a>
<h2>Overview</h2>
<p class="body">
OK, so you have finally decided to write your own Check.
Welcome aboard, this is really a fun thing to do. There are
actually two kinds of Checks, so before you can start, you have
to find out which kind of Check you want to implement.
</p>
<p class="body"> The functionality of Checkstyle is implemented in
modules that can be plugged into Checkstyle. Modules can be containers
for other modules, i.e. they form a tree structure. The toplevel modules
that are known directly to the Checkstyle kernel (which is also a module
and forms the root of the tree) implement the <a
href="api/com/puppycrawl/tools/checkstyle/api/FileSetCheck.html">FileSetCheck</a>
interface. These are pretty simple to grasp: they take a set of input
files and fire error messages. </p>
<p class="body"> Checkstyle provides a few FileSetCheck implementations
by default and one of them happens to be the <a
href="api/com/puppycrawl/tools/checkstyle/TreeWalker.html">TreeWalker</a>. A
TreeWalker supports submodules that are derived from the <a
href="api/com/puppycrawl/tools/checkstyle/api/Check.html">Check</a>
class. The TreeWalker operates by separately transforming each of the
Java input files into an abstract syntax tree and then handing the
result over to each of the Check submodules which in turn have a look at
a certain aspect of the tree. </p>
<a name="checks"></a>
<h2>Writing Checks</h2>
<p class="body">
Most of the functionality of Checkstyle is implemented as
Checks. If you know how to write your own Checks, you can extend
Checkstyle according to your needs without having to wait for
the Checkstyle development team. You are about to become a
Checkstyle Expert.
</p>
<p class="body">
Suppose you have a convention that the number of methods in a
class should not exceed a certain limit, say 30. This rule makes
sense, a class should only do one thing and do it well. With a
zillion methods chances are that the class does more than one
thing. The only problem you have is that your convention is not
checked by Checkstyle, so you&#39;ll have to write your own Check
and plug it into the Checkstyle framework.
</p>
<p class="body"> This chapter is organized as a tour that takes you
through the process step by step and explains both the theoretical
foundations and the <a
href="api/com/puppycrawl/tools/checkstyle/api/package-summary.html">Checkstyle
API</a> along the way. </p>
<a name="grammar"></a>
<h3>Java Grammar</h3>
<p class="body">
Every Java Program is structured into files, and each of these
files has a certain structure. For example, if there is a
package statement then it is the first line of the file that is
not comment or whitespace. After the package statement comes a
list of import statements, which is followed by a class or
interface definition, and so on.
</p>
<p class="body">
If you have ever read an introductory level Java book you probably
knew all of the above. And if you have studied computer science,
you probably also know that the rules that specify the Java language
can be formally specified using a grammar (statement is simplified
for didactic purposes).
</p>
<p class="body">
Tools exist which read a grammar definition and produce a parser
for the language that is specified in the grammar. In other
words, the output of the tool is a program that can transform a
stream of characters (a Java file) into a tree representation
that reflects the structure of the file. Checkstyle uses the
parser generator <a href="http://www.antlr.org">ANTLR</a> but
that is an implementation detail you do not need to worry about
when writing Checks. Several other parser generators exist and
they all work well.
</p>
<a name="gui"></a>
<h3>The Checkstyle SDK gui</h3>
<p class="body">
Still with us? Great, you have mastered the basic theory so here
is your reward - a gui that displays the structure of a Java
source file. To run it type
</p>
<pre>
java -classpath checkstyle-all-@CHECKSTYLE_VERSION@.jar \
com.puppycrawl.tools.checkstyle.gui.Main
</pre>
<p class="body">
on the command line. Click the button at the bottom of the frame
and select a syntactically correct Java source file. The frame
will be populated with a tree that corresponds to the structure
of the Java source code.
</p>
<p class="body">
<img alt="screenshot" src="gui_screenshot.png"/>
</p>
<p class="body"> In the leftmost column you can open and close branches
of the tree, the remaining columns display information about each node
in the tree. The second column displays a token type for each node. As
you navigate from the root of the tree to one of the leafs, you&#39;ll
notice that the token type denotes smaller and smaller units of your
source file, i.e. close to the root you might see the token type <a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CLASS_DEF">CLASS_DEF</a>
(a node that represents a class definition) while you will see token
types like IDENT (an identifier) near the leaves of the tree. </p>
<p class="body">
We&#39;ll get back to the details in the other columns later, they
are important for implementing Checks but not for understanding
the basic concepts. For now it is sufficient to know that the
gui is a tool that lets you look at the structure of a Java
file, i.e. you can see the Java grammar &#39;in action&#39;.
</p>
<a name="visitor"></a>
<h3>Understanding the visitor pattern</h3>
<p class="body">
Ready for a bit more theory? The last bit
that is missing before you can start writing Checks is understanding
the Visitor pattern.
</p>
<p class="body">
When working with ASTs, a simple approach to define check operations
on them would be to add a <span class="code">check()</span> method to the Class that defines
the AST nodes. For example, our AST type could have a method
<span class="code">checkNumberOfMethods()</span>. Such an approach would suffer from a few
serious drawbacks. Most importantly, it does not provide an extensible
design, i.e. the Checks have to be known at compile time; there is no
way to write plugins.
</p>
<p class="body"> Hence Checkstyle&#39;s AST classes do not have any
methods that implement checking functionality. Instead,
Checkstyle&#39;s <a
href="api/com/puppycrawl/tools/checkstyle/TreeWalker.html">TreeWalker</a>
takes a set of objects that conform to a <a
href="api/com/puppycrawl/tools/checkstyle/api/Check.html">Check</a>
interface. OK, you&#39;re right - actually it&#39;s not an interface
but an abstract class to provide some helper methods. A Check provides
methods that take an AST as an argument and perform the checking process
for that AST, most prominently <a
href="api/com/puppycrawl/tools/checkstyle/api/Check.html#visitToken(com.puppycrawl.tools.checkstyle.api.DetailAST)"><span
class="code">visitToken()</span></a>. </p>
<p class="body"> It is important to understand that the individual
Checks do no drive the AST traversal. Instead, the TreeWalker initiates
a recursive descend from the root of the AST to the leaf nodes and calls
the Check methods. The traversal is done using a <a
href="http://mathworld.wolfram.com/Depth-FirstTraversal.html">depth-first</a>
algorithm. </p>
<p class="body"> Before any visitor method is called, the TreeWalker
will call <a
href="api/com/puppycrawl/tools/checkstyle/api/Check.html#beginTree(com.puppycrawl.tools.checkstyle.api.DetailAST)"><span
class="code">beginTree()</span></a> to give the Check a chance to do
some initialization. Then, when performing the recursive descend from
the root to the leaf nodes, the <span class="code">visitToken()</span>
method is called. Unlike the basic examples in the pattern book, there
is a <span class="code">visitToken()</span> counterpart called <a
href="api/com/puppycrawl/tools/checkstyle/api/Check.html#leaveToken(com.puppycrawl.tools.checkstyle.api.DetailAST)"><span
class="code">leaveToken()</span></a>. The TreeWalker will call that
method to signal that the subtree below the node has been processed and
the TreeWalker is backtracking from the node. After the root node has
been left, the TreeWalker will call <a
href="api/com/puppycrawl/tools/checkstyle/api/Check.html#finishTree(com.puppycrawl.tools.checkstyle.api.DetailAST)"><span
class="code">finishTree()</span></a>. </p>
<p class="body">
If you&#39;d like to learn more about the Visitor pattern you should
grab a copy of the Gof
<a href="http://c2.com/cgi/wiki?DesignPatternsBook">Design
Patterns</a> book.
</p>
<a name="regtokens"></a>
<h3>Visitor in action</h3>
<p class="body">
Let&#39;s get back to our example and start writing code - that&#39;s why
you came here, right?
When you fire up the Checkstyle GUI and look at a few source
files you&#39;ll figure out pretty quickly that you are mainly
interested in the number of tree nodes of type METHOD_DEF. The
number of such tokens should be counted separately for each
CLASS_DEF / INTERFACE_DEF.
</p>
<p class="body">
Hence we need to register the Check for the token types
CLASS_DEF and INTERFACE_DEF. The TreeWalker will only call
visitToken for these token types. Because the requirements of
our tasks are so simple, there is no need to implement the other
fancy methods, like <span class="code">finishTree()</span>, etc., so here is our first
shot at our Check implementation:
</p>
<pre>
package com.mycompany.checks;
import com.puppycrawl.tools.checkstyle.api.*;
public class MethodLimitCheck extends Check
{
private int max = 30;
public int[] getDefaultTokens()
{
return new int[]{TokenTypes.CLASS_DEF, TokenTypes.INTERFACE_DEF};
}
public void visitToken(DetailAST ast)
{
// find the OBJBLOCK node below the CLASS_DEF/INTERFACE_DEF
DetailAST objBlock = ast.findFirstToken(TokenTypes.OBJBLOCK);
// count the number of direct children of the OBJBLOCK
// that are METHOD_DEFS
int methodDefs = objBlock.getChildCount(TokenTypes.METHOD_DEF);
// report error if limit is reached
if (methodDefs > max) {
log(ast.getLineNo(),
"too many methods, only " + max + " are allowed");
}
}
}
</pre>
<a name="astnav"></a>
<h3>Navigating the Abstract Syntax Tree (AST)</h3>
<p class="body">
In the example above you already saw that the DetailsAST class
provides utility methods to extract information from the tree, like
<span class="code">getChildCount()</span>. By now you have probably consulted the api
documentation and found that DetailsAST additionally provides methods
for navigating around in the syntax tree, like finding the next
sibling of a node, the children of a node, the parent of a node, etc.
</p>
<p class="body">
These methods provide great power for developing complex
Checks. Most of the Checks that Checkstyle provides by default
use these methods to analyze the environment of the ASTs that
are visited by the TreeWalker. Don&#39;t abuse that feature for
exploring the whole tree, though. Let the TreeWalker drive the
tree traversal and limit the visitor to the neighbours of a
single AST.
</p>
<a name="configchecks"></a>
<h3>Defining Check Properties</h3>
<p class="body">
Ok Mr. Checkstyle, that&#39;s all very nice but in my company we
have several projects, and each has another number of allowed
methods. I need to control my Check through properties, so where
is the API to do that?
</p>
<p class="body">
Well, the short answer is, there is no API. It&#39;s magic. Really!
</p>
<p class="body">
If you need to make something configurable, just add a setter method
to the Check:
</p>
<pre>
public class MethodLimitCheck extends Check
{
// code from above omitted for brevity
public void setMax(int limit)
{
max = limit;
}
}
</pre>
<p class="body">
With this code added, you can set the property <span
class="code">max</span> for the MethodLimitCheck module in the
configuration file. It doesn&#39;t get any simpler than that. The secret is
that Checkstyle uses JavaBean introspection to set the JavaBean
properties. That works for all primitive types like boolean,
int, long, etc., plus Strings, plus arrays of these types.
</p>
<a name="logerrors"></a>
<h3>Logging errors</h3>
<p class="body">
Detecting errors is one thing, presenting them to the user is
another. To do that, the Check base class provides several log
methods, the simplest of them being <span class="code">Check.log(String)</span>. In your
Check you can simply use a verbatim error string like in <span
class="code">log(&quot;Too many methods, only &quot; + mMax +
&quot; are allowed&quot;);</span> as the argument. That will
work, but it&#39;s not the best possible solution if your Check is
intended for a wider audience.
</p>
<p class="body">
If you are not living in a country where people speak English,
you may have noticed that Checkstyle writes internationalized
error messages, for example if you live in Germany the error
messages are German. The individual Checks don&#39;t have to do
anything fancy to achieve this, it&#39;s actually quite easy and the
Checkstyle framework does most of the work.
</p>
<p class="body">
To support internationalized error messages, you need to create
a message.properties file alongside your Check class, i.e. the
Java file and the properties files should be in the same
directory. Add a symbolic error code and an English
representation to the messages.properties. The file should
contain the following line: <span
class="code">too.many.methods=Too many methods, only {0} are
allowed</span>. Then replace the verbatim error message with
the symbolic representation and use one of the log helper
methods to provide the dynamic part of the message (mMax in this
case): <span class="code">log(&quot;too.many.methods&quot;,
mMax);</span>. Please consult the documentation of Java&#39;s <a
href="http://java.sun.com/j2se/1.4.1/docs/api/java/text/MessageFormat.html">MessageFormat</a>
to learn about the syntax of format strings (especially about
those funny numbers in the translated text).
</p>
<p class="body">
Supporting a new language is very easy now, simply create a new
messages file for the language, e.g. messages_fr.properties to
provide french error messages. The correct file will be chosen
automatically, based on the language settings of the user&#39;s
operating system.
</p>
<a name="integrate"></a>
<h3>Integrate your Check</h3>
<p class="body">
The great final moment has arrived, you are about to run your
Check. To integrate your Check, add a new subentry under the
TreeWalker module of your configuration file. Use the full
classname of your Check class as the name of the module.
Your configuration file should look something like this:
</p>
<pre>
&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;!DOCTYPE module PUBLIC
&quot;-//Puppy Crawl//DTD Check Configuration 1.2//EN&quot;
&quot;http://www.puppycrawl.com/dtds/configuration_1_2.dtd&quot;&gt;
&lt;module name=&quot;Checker&quot;&gt;
&lt;module name=&quot;TreeWalker&quot;&gt;
&lt;!-- your standard Checks that come with Checkstyle --&gt;
&lt;module name=&quot;UpperEll&quot;/&gt;
&lt;module name=&quot;MethodLength&quot;/&gt;
&lt;!-- your Check goes here --&gt;
&lt;module name=&quot;com.mycompany.checks.MethodLimitCheck&quot;&gt;
&lt;property name=&quot;max&quot; value=&quot;45&quot;/&gt;
&lt;/module&gt;
&lt;/module&gt;
&lt;/module&gt;
</pre>
<p class="body">
To run the new Check on the command line compile your Check,
create a jar that contains the classes and property files,
e.g. <span class="code">mycompanychecks.jar</span>. Then run
(with the path separator adjusted to your platform):
</p>
<pre>
java -classpath mycompanychecks.jar:checkstyle-all-@CHECKSTYLE_VERSION@.jar \
com.puppycrawl.tools.checkstyle.Main \
-c config.xml -r .
</pre>
<p class="body">
Did you see all those errors about &quot;too many methods&quot;
flying over your screen? Congratulations. You can now consider
yourself a Checkstyle expert. Go to your fridge. Have a beer.
</p>
<p class="body">
Please consult the <a href="config.html#packagenames">Checkstyle
configuration manual</a> to learn how to integrate your Checks
into the package configuration so that you can use <span
class="code">MethodLimit</span> instead of the full class name.
</p>
<a name="limitations"></a>
<h3>Limitations</h3>
<p class="body">
OK, so you have written your first Check, and you have found
several flaws in many of your programs. You now know that your
boss does not follow the coding conventions he wrote. And you
know that you are the king of the world. To become a programming
god, you want to write your second Check - now wait, first you
should know what your limits are.
</p>
<p class="body">
There are basically only two of them:
</p>
<ul>
<li class="body">You cannot determine the type of an expression.</li>
<li class="body">You cannot see the content of other files.</li>
</ul>
<p class="body">
This means that you cannot implement some of the code inspection
features that are available in advanced IDEs like <a
href="http://www.intellij.com/idea/">IntelliJ IDEA</a>. For
example you will not be able to implement a Check that finds
redundant type casts or unused public methods.
</p>
<a name="filesetchecks"></a>
<h2>Writing FileSetChecks</h2>
<p class="body"> Writing a FileSetCheck is pretty straightforward: Just
inherit from <a
href="api/com/puppycrawl/tools/checkstyle/api/AbstractFileSetCheck.html">AbstractFileSetCheck</a>
and implement the <a
href="api/com/puppycrawl/tools/checkstyle/api/FileSetCheck.html#process(java.io.File[])"><span
class="code">process(File[] files)</span></a> method and you&#39;re
done. A very simple example could fire an error if the number of files
that are passed in exceeds a certain limit. Here is a FileSetCheck that does just that:</p>
<pre>
package com.mycompany.checks;
import java.io.File;
import com.puppycrawl.tools.checkstyle.api.*;
public class LimitImplementationFiles
extends AbstractFileSetCheck
{
private int max = 100;
public void setMax(int aMax)
{
max = aMax;
}
public void process(File[] files)
{
if (files != null &amp;&amp; files.length > max) {
// figure out the file that contains the error
final String path = files[max].getPath();
// message collector is used to collect error messages,
// needs to be reset before starting to collect error messages
// for a file.
getMessageCollector().reset();
// message dispatcher is used to fire AuditEvents
MessageDispatcher dispatcher = getMessageDispatcher();
// signal start of file to AuditListeners
dispatcher.fireFileStarted(path);
// log the message
log(0, "max.files.exceeded", new Integer(max));
// you can call log() multiple times to flag multiple
// errors in the same file
// fire the errors for this file to the AuditListeners
fireErrors(path);
// signal end of file to AuditListeners
dispatcher.fireFileFinished(path);
}
}
}
</pre>
<p class="body">
Note that the configuration via bean introspection also applies
here. By implementing the <span class="code">setMax()</span> method the FileSetCheck
automatically makes &quot;max&quot; a legal configuration
parameter that you can use in the Checkstyle configuration file.
</p>
<p class="body">
There are virtually no limits what you can do in
FileSetChecks. The craziest ideas we&#39;ve had so far are:
</p>
<ul>
<li class="body">to find global code problems like unused public methods.</li>
<li class="body">to find duplicate code.</li>
<li class="body">to port the TreeWalker solution to check C#
instead of Java.</li>
</ul>
<a name="huh"></a>
<h2>Huh? I can&#39;t figure it out!</h2>
<p class="body">
That&#39;s probably our fault, and it means that we have to provide
better documentation. Please do not hesitate to ask questions on
the user mailing list, this will help us to improve this
document. Please ask your questions as precisely as possible.
We will not be able to answer questions like &quot;I want to
write a Check but I don&#39;t know how, can you help me?&quot;. Tell
us what you are trying to do (the purpose of the Check), what
you have understood so far, and what exactly you are getting stuck
on.
</p>
<a name="contributeback"></a>
<h2>Contributing</h2>
<p class="body">
We need <em>your</em> help to keep improving Checkstyle.
Whenever you write a Check or FileSetCheck that you think is
generally useful, please consider
<a href="contributing.html">contributing</a> it to the
Checkstyle community and submit it for inclusion in the next
release of Checkstyle.
</p>
</td>
</tr>
</table>
<hr/>
<div><a href="index.html">Back to the Checkstyle Home Page</a></div>
<p class="copyright">Copyright &copy; 2002-2004 Oliver Burn. All rights Reserved.</p>
</body> </html>

View File

@ -1,164 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Writing your own filters</title>
<link rel="stylesheet" type="text/css" href="mystyle.css"/>
</head>
<body>
<!-- The header -->
<table border="0" width="100%" summary="header layout">
<tr>
<td><h1>Writing your own Filters</h1></td>
<td align="right"><img src="logo.png" alt="Checkstyle Logo"/></td>
</tr>
</table>
<!-- content -->
<table border="0" width="100%" cellpadding="5" summary="body layout">
<tr>
<!--Left menu-->
<td class="menu" valign="top">
<p>
<a href="#overview">Overview</a>
</p>
<p>
<a href="#writing">Writing Filters</a>
</p>
<p>
<a href="#using">Using Filters</a>
</p>
<p>
<a href="#huh">Huh?</a>
</p>
<p>
<a href="#contributeback">Contributing</a>
</p>
</td>
<!--Content-->
<td class="content" valign="top" align="left"><a name="overview"></a> <h2>Overview</h2>
<p class="body">
A <span class="code">Checker</span> has a set of <span class="code">Filter</span>s
that decide which audit events the <span class="code">Checker</span> reports through its listeners.
Interface <span class="code">Filter</span> and class <span class="code">FilterSet</span>
are intended to support general <span class="code">AuditEvent</span> filtering using a set of <span class="code">Filter</span>s.
<p>
<p class="body">
A <span class="code">Filter</span> has <span class="code">boolean</span> method <span class="code">accept(AuditEvent)</span>
that returns <span class="code">true</span> if the <span class="code">Filter</span> accepts the
<span class="code">AuditEvent</span> parameter and returns <span class="code">false</span> if the <span class="code">Filter</span>
rejects it.
</p>
<p class="body">
A <span class="code">FilterSet</span> is a particular <span class="code">Filter</span>
that contains a set of <span class="code">Filter</span>s. A <span class="code">FilterSet</span> accepts an
<span class="code">AuditEvent</span> if and only if
all <span class="code">Filter</span>s in the set accept the <span class="code">AuditEvent</span>.
</p>
<p class="body">
Here is a UML diagram for interface <span class="code">Filter</span>
and class <span class="code">FilterSet</span>.
</p>
<img src="Filter.gif" width="233" height="324" alt="Filter UML diagram"/>
<a name="writing"></a> <h2>Writing Filters</h2>
<p class="body">
The <span class="code">Filter</span> that we demonstrate here rejects audit events for files whose name matches a
<a href="property_types.html#regexp">regular expression</a>.
In order to enable the specification of the file name pattern as a property in a configuration file,
the <span class="code">Filter</span> is an
<a href="api/com/puppycrawl/tools/checkstyle/api/AutomaticBean.html">AutomaticBean</a>
with mutator method <span class="code">setFiles(String)</span> that receives the file name pattern.
An <span class="code">AutomaticBean</span> uses JavaBean introspection to set JavaBean properties such as
<span class="code">files</span>.
</p>
<pre class="body">
package com.mycompany.filters;
import org.apache.regexp.RE;
import org.apache.regexp.RESyntaxException;
import com.puppycrawl.tools.checkstyle.api.AuditEvent;
import com.puppycrawl.tools.checkstyle.api.AutomaticBean;
import com.puppycrawl.tools.checkstyle.api.Filter;
import com.puppycrawl.tools.checkstyle.api.Utils;
public class FilesFilter
extends AutomaticBean
implements Filter
{
private RE mFileRegexp;
public FilesFilter()
throws RESyntaxException
{
setFiles("^$");
}
public boolean accept(AuditEvent aEvent)
{
final String fileName = aEvent.getFileName();
return ((fileName == null) || !mFileRegexp.match(fileName));
}
public void setFiles(String aFilesPattern)
throws RESyntaxException
{
mFileRegexp = Utils.getRE(aFilesPattern);
}
}
</pre>
<a name="using"></a> <h2>Using Filters</h2>
<p class="body">
To incorporate a <span class="code">Filter</span> in the filter set for a <span class="code">Checker</span>,
include a module element for the <span class="code">Filter</span> in the
<a href="config.html#filters">configuration file<a>. For example, to configure a <span class="code">Checker</span>
so that it uses custom filter <span class="code">FilesFilter</span> to prevent reporting of
audit events for files whose name contains &quot;Generated&quot;, include the following module in the
configuration file:
</p>
<pre class="body">
&lt;module name=&quot;com.mycompany.filters.FilesFilter&quot;&gt;
&lt;property name=&quot;files&quot; value=&quot;Generated&quot;/&gt;
&lt;/module&gt;
</pre>
<a name="huh"></a> <h2>Huh? I can&#39;t figure it out!</h2>
<p class="body">
That&#39;s probably our fault, and it means that we have to provide better
documentation. Please do not hesitate to ask questions on the user mailing list,
this will help us to improve this document. Please ask your questions as
precisely as possible. We will not be able to answer questions like &quot;I want
to write a filter but I don&#39;t know how, can you help me?&quot;. Tell us
what you are trying to do (the purpose of the filter), what you have
understood so far, and what exactly you are getting stuck on.
</p>
<a name="contributeback"></a> <h2>Contributing</h2>
<p class="body">
We need <em>your</em> help to keep improving Checkstyle.
Whenever you write a filter that you think is generally useful, please
consider <a href="contributing.html">contributing</a> it to the Checkstyle
community and submit it for inclusion in the next release of Checkstyle.
</p>
</td>
</tr>
</table>
<hr/>
<div>
<a href="index.html">Back to the Checkstyle Home Page</a>
</div>
<p class="copyright">
Copyright &copy; 2002-2004 Oliver Burn. All rights Reserved.
</p>
</body>
</html>

View File

@ -1,369 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Writing your own listeners</title>
<link rel="stylesheet" type="text/css" href="mystyle.css"/>
</head>
<body>
<!-- The header -->
<table border="0" width="100%" summary="header layout">
<tr>
<td><h1>Writing your own Listeners</h1></td>
<td align="right"><img src="logo.png" alt="Checkstyle Logo"/></td>
</tr>
</table>
<!-- content -->
<table border="0" width="100%" cellpadding="5" summary="body layout">
<tr>
<!--Left menu-->
<td class="menu" valign="top">
<p>
<a href="#overview">Overview</a>
</p>
<p>
<a href="#writing">Writing Listeners</a>
</p>
<p>
<a href="#using">Using Listeners</a>
</p>
<p>
<a href="#examples">Examples</a>
</p>
<ul>
<li>
<a href="#CommonsLoggingListener">CommonsLoggingListener</a>
</li>
<li>
<a href="#MailLogger">MailLogger</a>
</li>
</ul>
<p>
<a href="#huh">Huh?</a>
</p>
<p>
<a href="#contributeback">Contributing</a>
</p>
</td>
<!--Content-->
<td class="content" valign="top" align="left"><a name="overview"></a> <h2>Overview</h2>
<p class="body">
A Checkstyle listener monitors the progress of a <span class="code">Checker</span>
during the audit of files. The <span class="code">Checker</span> notifies its
attached listeners of significant events such as the start of the audit of a
file and the logging of a Check error, and the listeners respond appropriately.
Any number of listeners can be attached to a <span class="code">
Checker</span>. An audit always adds one of the distribution listeners, <a href="api/com/puppycrawl/tools/checkstyle/DefaultLogger.html">DefaultLogger</a>
or <a href="api/com/puppycrawl/tools/checkstyle/XMLLogger.html">XMLLogger</a>,
to report events. A <span class="code">DefaultLogger</span> produces simple text
output for the events it receives, and a <span class="code">XMLLogger</span>
produces an XML document for its events.
</p>
<p class="body">
Listeners <span class="code">DefaultLogger</span> and <span class="code">
XMLLogger</span> are sufficient for most Checkstyle users, but you may find a
need for a custom listener. For example, a user has requested verbose output of
progress information during a Checkstyle run. Another user would like to filter
error events. This document explains how to write listeners for such tasks and
how to integrate them in a Checker module. It also describes two custom
listeners that are inspired by ANT listeners: a listener that is a wrapper for
the Jakarta Commons Logging API, and a listener that sends its results via email.
</p>
<p class="body">
A listener is an implementation of the <a href="api/com/puppycrawl/tools/checkstyle/api/AuditListener.html">AuditListener</a>
interface. During an audit, a <span class="code">Checker</span> informs its
attached <span class="code">AuditListeners</span> of six kinds of events: audit
started/ended, file started/ended, and logging of an error/exception.
</p>
<p class="body">
An audit passes an event to a listener as an <a href="api/com/puppycrawl/tools/checkstyle/api/AuditEvent.html">AuditEvent</a>.
A file-related <span class="code">AuditEvent</span> contains the name of that
file. An <span class="code">AuditEvent</span> for error logging has a message, a
severity level, a message source such as the name of a <span class="code">Check</span>,
and file line and column numbers that may be relevant to the error. The
notification of an exception to a <span class="code">AuditListener</span>
includes an error <span class="code">AuditEvent</span> and the details of the
exception. Here is a UML diagram for classes <span class="code">AuditListener</span>
and <span class="code">AuditEvent</span>.
</p>
<img src="AuditListener.gif" width="381" height="488" alt="AuditListener UML diagram"/>
<a name="writing"></a> <h2>Writing Listeners</h2>
<p class="body">
A custom listener is an implementation of the <a href="api/com/puppycrawl/tools/checkstyle/api/AuditListener.html">AuditListener</a>
interface. If the listener has properties that can be set from a configuration, the listener must extend
<a href="api/com/puppycrawl/tools/checkstyle/api/AutomaticBean.html">AutomaticBean</a>.
An <span class="code">AutomaticBean</span> uses JavaBean introspection to set JavaBean properties.
</p>
<p class="body">
The custom listener that we demonstrate here is a verbose listener that simply
prints each event notification to an output stream, and reports the number of
errors per audited file and the total number of errors. The default output stream is
<span class="code">System.out</span>. In order to enable the specification of output to a file
through property <span class="code">file</span>,
the class extends <span class="code">AutomaticBean</span> and defines method
<span class="code">setFile(String)</span>.
</p>
<pre class="body">
package com.mycompany.listeners;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import com.puppycrawl.tools.checkstyle.api.AuditEvent;
import com.puppycrawl.tools.checkstyle.api.AuditListener;
import com.puppycrawl.tools.checkstyle.api.AutomaticBean;
import com.puppycrawl.tools.checkstyle.api.SeverityLevel;
public class VerboseListener
extends AutomaticBean
implements AuditListener
{
private PrintWriter mWriter = new PrintWriter(System.out);
private boolean mCloseOut = false;
private int mTotalErrors;
private int mErrors;
public void setFile(String aFileName)
throws FileNotFoundException
{
final OutputStream out = new FileOutputStream(aFileName);
mWriter = new PrintWriter(out);
mCloseOut = true;
}
public void auditStarted(AuditEvent aEvt)
{
mTotalErrors = 0;
mWriter.println("Audit started.");
}
public void auditFinished(AuditEvent aEvt)
{
mWriter.println("Audit finished. Total errors: " + mTotalErrors);
mWriter.flush();
if (mCloseOut) {
mWriter.close();
}
}
public void fileStarted(AuditEvent aEvt)
{
mErrors = 0;
mWriter.println(
"Started checking file '" + aEvt.getFileName() + "'.");
}
public void fileFinished(AuditEvent aEvt)
{
mWriter.println("Finished checking file '" + aEvt.getFileName()
+ "'. Errors: " + mErrors);
}
public void addError(AuditEvent aEvt)
{
printEvent(aEvt);
if (SeverityLevel.ERROR.equals(aEvt.getSeverityLevel())) {
mErrors++;
mTotalErrors++;
}
}
public void addException(AuditEvent aEvt, Throwable aThrowable)
{
printEvent(aEvt);
aThrowable.printStackTrace(System.out);
mErrors++;
mTotalErrors++;
}
private void printEvent(AuditEvent aEvt)
{
mWriter.println("Logging error -"
+ " file: '" + aEvt.getFileName() + "'"
+ " line: " + aEvt.getLine()
+ " column: " + aEvt.getColumn()
+ " severity: " + aEvt.getSeverityLevel()
+ " message: " + aEvt.getMessage()
+ " source: " + aEvt.getSourceName());
}
}
</pre>
<p class="body">
A listener that filters error events could perform the filtering in methods <span class="code">
addError</span> and <span class="code">addException</span>. As further examples
of listeners, <a href="#CommonsLoggingListener">CommonsLoggingListener</a>
reports its events through the Commons Logging API, and <a href="#MailLogger">MailLogger</a>
e-mails the audit report of a <span class="code">DefaultLogger</span>.
</p>
<a name="using"></a> <h2>Using Listeners</h2>
<p class="body">
To incorporate a custom listener in the set of listeners for a <span class="code">Checker</span>,
include a module element for the listener in the
<a href="config.html#auditlisteners">configuration file<a>. For example, to configure a <span class="code">Checker</span>
so that it uses custom listener <span class="code">VerboseListener</span> to print audit messages
to a file named &quot;audit.txt&quot;, include the following module in the
configuration file:
</p>
<pre class="body">
&lt;module name=&quot;com.mycompany.listeners.VerboseListener&quot;&gt;
&lt;property name=&quot;file&quot; value=&quot;audit.txt&quot;/&gt;
&lt;/module&gt;
</pre>
<p class="body">
Here is a truncated example of audit output from a <span class="code">
VerboseListener</span>:
</p>
<pre>
Audit started.
Started checking file 'CommonsLoggingListener.java'.
Finished checking file 'CommonsLoggingListener.java'. Errors: 0
Started checking file 'MailLogger.java'.
Finished checking file 'MailLogger.java'. Errors: 0
Started checking file 'VerboseListener.java'.
Logging error - file: 'VerboseListener.java' line: 23 ...
Finished checking file 'VerboseListener.java'. Errors: 1
Audit finished. Total errors: 1
</pre>
<a name="examples"></a> <h2>Examples</h2>
<p class="body">
This section describes two examples based on <a href="http://ant.apache.org/">ANT</a> listeners. The first listener, <span class="code">
CommonsLoggingListener</span>, hands off events to the <a href="http://jakarta.apache.org/commons/logging.html">Jakarata
Commons Logging</a> fa&ccedil;ade and the second, <span class="code">MailLogger</span>,
sends a report of an audit via e-mail. The discussion of these examples and how
to use them is derived from material in <a href="http://www.manning.com/antbook">&quot;Java
Development with Ant&quot;</a> by Eric Hatcher and Steve Loughran, an excellent
ANT book.
<a name="CommonsLoggingListener"></a><h4>CommonsLoggingListener</h4>
<p class="body">
<a href="http://jakarta.apache.org/commons/logging.html">Jakarata Commons
Logging</a> provides a fa&ccedil;ade for logging tools <a href="http://jakarta.apache.org/log4j/docs/index.html">log4j</a>,
<a href="http://jakarta.apache.org/avalon/logkit/index.html">Avalon LogKit</a>,
J2SE 1.4, and others. Checkstyle listener <span class="code">
CommonsLoggingListener</span> responds to an AuditEvent by handing it off to the
current Commons Logging Log.
</p>
<p class="body">
The source code for <span class="code">CommonsLoggingListener</span> is in
distribution directory <span class="default">contrib/examples/listeners</span>.
Notice that each <span class="code">AuditListener</span> method that receives an <span class="code">
AuditEvent</span> calls a method for the Commons Logging log level corresponding
to the Checkstyle <span class="code">SeverityLevel</span> of the <span class="code">
AuditEvent</span>.
</p>
<p class="body">
The easiest way to use <span class="code">CommonsLoggingListener</span> is to
include <span class="default">checkstyle-all-@CHECKSTYLE_VERSION@.jar</span> in
the classpath because that jar file contains all the Commons Logging classes.
The default Log under J2SE 1.4 is wrapper class <a href="http://jakarta.apache.org/commons/logging/api/org/apache/commons/logging/impl/Jdk14Logger.html">Jdk14Logger</a>.
Under earlier Java versions, the default Log is a simple wrapper class, <a href="http://jakarta.apache.org/commons/logging/api/org/apache/commons/logging/impl/SimpleLog.html">SimpleLog</a>.
Both default logging tools can be used directly from Commons Logging; if you
need to use other tools such as log4j, then you must include the appropriate jar
file(s) in the classpath.
</p>
<p class="body">
Logging configuration details for Jakarta Commons Logging are in the <a href="http://jakarta.apache.org/commons/logging.html">documentation</a>.
As a simple example, assume that <span class="default">log4j.jar</span> is in
the classpath and the following <span class="default">log4j.properties</span>
file is in the current directory:
</p>
<pre>
# Set root logger level to INFO and its only appender to A1.
log4j.rootLogger=INFO, A1
# A1 is set to be a ConsoleAppender.
log4j.appender.A1=org.apache.log4j.ConsoleAppender
# A1 uses PatternLayout.
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-5p %c %x- %m%n
</pre>
<p class="body">
Running a Checkstyle audit with a <span class="code">CommonsLoggingListener</span>
yields this (abbreviated) output:
</p>
<pre>
INFO com.puppycrawl...Checker - Audit started.
INFO com.puppycrawl...Checker - File "CommonsLoggingListener.java" started.
INFO com.puppycrawl...Checker - File "CommonsLoggingListener.java" finished.
INFO com.puppycrawl...Checker - File "MailLogger.java" started.
INFO com.puppycrawl...Checker - File "MailLogger.java" finished.
INFO com.puppycrawl...Checker - File "VerboseListener.java" started.
ERROR com.puppycrawl...ParenPadCheck - Line: 23 Column: 28 ...
INFO com.puppycrawl...Checker - File "VerboseListener.java" finished.
INFO com.puppycrawl...Checker - Audit finished.
</pre>
<a name="MailLogger"></a><h4>MailLogger</h4>
<p class="body">
<span class="code">MailLogger</span> sends an audit report in an email message.
The listener uses a <span class="code">DefaultLogger</span> to prepare the text
of the message. The listener obtains other message
parameters such as <span class="default">to</span> and <span class="default">subject</span>
from environment properties that can be read from a properties file.
</p>
<p class="body">
The source code for <span class="code">CommonsLoggingListener</span> is in
distribution directory <span class="default">contrib/examples/listeners</span>.
This implementation uses the <a href="http://java.sun.com/products/javamail">JavaMail API</a>
as the mail system, and you must include appropriate jar files in the classpath.
</p>
<p class="body">
As an example of using <span class="code">MailLogger</span>,
set system property <span class="default">-DMailLogger.properties.file=MailLogger.properties</span>,
so that <span class="code">MailLogger</span> reads message parameters from file
<span class="default">MailLogger.properties</span> of the current directory:
</p>
<pre>
MailLogger.from=user@example.org
MailLogger.failure.to=user@example.org
MailLogger.success.to=user@example.org
MailLogger.mailhost=localhost
</pre>
<a name="huh"></a> <h2>Huh? I can&#39;t figure it out!</h2>
<p class="body">
That&#39;s probably our fault, and it means that we have to provide better
documentation. Please do not hesitate to ask questions on the user mailing list,
this will help us to improve this document. Please ask your questions as
precisely as possible. We will not be able to answer questions like &quot;I want
to write a listener but I don&#39;t know how, can you help me?&quot;. Tell us
what you are trying to do (the purpose of the listener), what you have
understood so far, and what exactly you are getting stuck on.
</p>
<a name="contributeback"></a> <h2>Contributing</h2>
<p class="body">
We need <em>your</em> help to keep improving Checkstyle.
Whenever you write a listener that you think is generally useful, please
consider <a href="contributing.html">contributing</a> it to the Checkstyle
community and submit it for inclusion in the next release of Checkstyle.
</p>
</td>
</tr>
</table>
<hr/>
<div>
<a href="index.html">Back to the Checkstyle Home Page</a>
</div>
<p class="copyright">
Copyright &copy; 2002-2004 Oliver Burn. All rights Reserved.
</p>
</body>
</html>

View File

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- DTD for XMLLogger output -->
<!ELEMENT checkstyle (file)*>
<!ATTLIST checkstyle version CDATA #REQUIRED>
<!ELEMENT file (error)*>
<!ATTLIST file name CDATA #REQUIRED>
<!ELEMENT error EMPTY>
<!ATTLIST error
line NMTOKEN #REQUIRED
column NMTOKEN #IMPLIED
severity CDATA #REQUIRED
message CDATA #REQUIRED
source CDATA #REQUIRED
>