copyright year 2004
This commit is contained in:
parent
ab4b11645f
commit
22d78fa990
|
|
@ -271,6 +271,6 @@ provide a package names file</b>
|
|||
</pre>
|
||||
|
||||
<hr />
|
||||
<p class="copyright">Copyright © 2002-2003 Oliver Burn. All rights Reserved.</p>
|
||||
<p class="copyright">Copyright © 2002-2004 Oliver Burn. All rights Reserved.</p>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ provide a package names file</b>
|
|||
<div class="tip">
|
||||
<h4 class="tip">Tip</h4>
|
||||
<p>
|
||||
It is possible to run Checkstyle directly from the JAR file using the
|
||||
It is possible to run Checkstyle directly from the JAR file using the
|
||||
<span class="code">-jar</span> option. An example would be:
|
||||
</p>
|
||||
|
||||
|
|
@ -156,6 +156,6 @@ provide a package names file</b>
|
|||
|
||||
<hr />
|
||||
<div><a href="index.html">Back to the Checkstyle Home Page</a></div>
|
||||
<p class="copyright">Copyright © 2002-2003 Oliver Burn. All rights Reserved.</p>
|
||||
<p class="copyright">Copyright © 2002-2004 Oliver Burn. All rights Reserved.</p>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -826,7 +826,7 @@
|
|||
<hr />
|
||||
<div><a href="index.html">Back to the Checkstyle Home Page</a></div>
|
||||
<p class="copyright">
|
||||
Copyright © 2002-2003 Oliver Burn. All rights Reserved.
|
||||
Copyright © 2002-2004 Oliver Burn. All rights Reserved.
|
||||
</p>
|
||||
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -259,7 +259,7 @@
|
|||
<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>
|
||||
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>
|
||||
|
|
@ -430,7 +430,7 @@ switch (a)
|
|||
<hr />
|
||||
<div><a href="index.html">Back to the Checkstyle Home Page</a></div>
|
||||
<p class="copyright">
|
||||
Copyright © 2002-2003 Oliver Burn. All rights Reserved.
|
||||
Copyright © 2002-2004 Oliver Burn. All rights Reserved.
|
||||
</p>
|
||||
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -1620,7 +1620,7 @@ return !valid();
|
|||
<hr />
|
||||
<div><a href="index.html">Back to the Checkstyle Home Page</a></div>
|
||||
<p class="copyright">
|
||||
Copyright © 2002-2003 Oliver Burn. All rights Reserved.
|
||||
Copyright © 2002-2004 Oliver Burn. All rights Reserved.
|
||||
</p>
|
||||
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -408,7 +408,7 @@ public class StringUtils // not final to allow subclassing
|
|||
<hr />
|
||||
<div><a href="index.html">Back to the Checkstyle Home Page</a></div>
|
||||
<p class="copyright">
|
||||
Copyright © 2002-2003 Oliver Burn. All rights Reserved.
|
||||
Copyright © 2002-2004 Oliver Burn. All rights Reserved.
|
||||
</p>
|
||||
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ Checkstyle plugins for duplicate code detection:
|
|||
<hr />
|
||||
<div><a href="index.html">Back to the Checkstyle Home Page</a></div>
|
||||
<p class="copyright">
|
||||
Copyright © 2002-2003 Oliver Burn. All rights Reserved.
|
||||
Copyright © 2002-2004 Oliver Burn. All rights Reserved.
|
||||
</p>
|
||||
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -39,9 +39,9 @@
|
|||
headerFile</span> specifies a file that contains the required header.
|
||||
</p>
|
||||
<p class="body">
|
||||
Property <span class="code">ignoreLines</span> specifies the line numbers to
|
||||
ignore when matching lines in a header file. This property is very useful for
|
||||
supporting headers that contain copyright dates. For example, consider the
|
||||
Property <span class="code">ignoreLines</span> specifies the line numbers to
|
||||
ignore when matching lines in a header file. This property is very useful for
|
||||
supporting headers that contain copyright dates. For example, consider the
|
||||
following header:
|
||||
</p>
|
||||
<pre class="body">
|
||||
|
|
@ -52,7 +52,7 @@ line 4: // Copyright (C) 2002 Oliver Burn
|
|||
line 5: ////////////////////////////////////////////////////////////////////
|
||||
</pre>
|
||||
<p class="body">
|
||||
Since the year information will change over time, you can tell Checkstyle to
|
||||
Since the year information will change over time, you can tell Checkstyle to
|
||||
ignore line 4 by setting property <span class="code">ignoreLines</span> to <span class="code">
|
||||
4</span>.
|
||||
</p>
|
||||
|
|
@ -80,7 +80,7 @@ line 5: ////////////////////////////////////////////////////////////////////
|
|||
|
||||
<h4>Example</h4>
|
||||
<p class="body">
|
||||
To configure the check to use header file <span class="code">"java.header"</span>
|
||||
To configure the check to use header file <span class="code">"java.header"</span>
|
||||
and ignore lines <span class="code">2</span>, <span class="code">3</span>, and <span class="code">
|
||||
4</span>:
|
||||
</p>
|
||||
|
|
@ -100,12 +100,12 @@ line 5: ////////////////////////////////////////////////////////////////////
|
|||
</p>
|
||||
<a name="RegexpHeader"></a> <h2>RegexpHeader</h2> <h4>Description</h4>
|
||||
<p class="body">
|
||||
Checks the header of a source file against a header file that contains a <a href="http://jakarta.apache.org/regexp/apidocs/org/apache/regexp/RE.html">regular
|
||||
Checks the header of a source file against a header file that contains a <a href="http://jakarta.apache.org/regexp/apidocs/org/apache/regexp/RE.html">regular
|
||||
expression</a> for each line of the source header.
|
||||
</p>
|
||||
<p class="body">
|
||||
Rationale: In some projects <a href="#Header">checking against a fixed header</a>
|
||||
is not sufficient, e.g. the header might require a copyright line where the year
|
||||
Rationale: In some projects <a href="#Header">checking against a fixed header</a>
|
||||
is not sufficient, e.g. the header might require a copyright line where the year
|
||||
information is not static.
|
||||
</p>
|
||||
<p class="body">
|
||||
|
|
@ -118,7 +118,7 @@ line 3: ^// Checks Java source code for adherence to a set of rules\.$
|
|||
line 4: ^// Copyright \(C\) \d\d\d\d Oliver Burn$
|
||||
line 5: ^// Last modification by \$Author.*\$$
|
||||
line 6: ^/{71}$
|
||||
line 7:
|
||||
line 7:
|
||||
line 8: ^package
|
||||
line 9:
|
||||
line 10: ^import
|
||||
|
|
@ -190,7 +190,7 @@ line 14: ^ \*/
|
|||
<hr />
|
||||
<div><a href="index.html">Back to the Checkstyle Home Page</a></div>
|
||||
<p class="copyright">
|
||||
Copyright © 2002-2003 Oliver Burn. All rights Reserved.
|
||||
Copyright © 2002-2004 Oliver Burn. All rights Reserved.
|
||||
</p>
|
||||
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -91,9 +91,9 @@
|
|||
<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
|
||||
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>
|
||||
|
|
@ -121,7 +121,7 @@
|
|||
<module name="IllegalImport"/>
|
||||
</pre>
|
||||
<p class="body">
|
||||
To configure the check so that it rejects packages <span class="code">java.io.*</span>
|
||||
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">
|
||||
|
|
@ -139,16 +139,16 @@
|
|||
</p>
|
||||
<a name="RedundantImport"></a> <h2>RedundantImport</h2> <h4>Description</h4>
|
||||
<p class="body">
|
||||
Checks for redundant import statements. An import statement is considered
|
||||
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
|
||||
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.
|
||||
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>
|
||||
|
|
@ -173,25 +173,25 @@
|
|||
</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
|
||||
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
|
||||
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
|
||||
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
|
||||
The class imported is from the <span class="code">java.lang</span> package. For
|
||||
example importing <span class="code">java.lang.String</span>.
|
||||
</li>
|
||||
|
||||
|
|
@ -288,7 +288,7 @@
|
|||
<hr />
|
||||
<div><a href="index.html">Back to the Checkstyle Home Page</a></div>
|
||||
<p class="copyright">
|
||||
Copyright © 2002-2003 Oliver Burn. All rights Reserved.
|
||||
Copyright © 2002-2004 Oliver Burn. All rights Reserved.
|
||||
</p>
|
||||
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -86,8 +86,8 @@
|
|||
<span class="code">static</span>.
|
||||
</li>
|
||||
<li class="body">
|
||||
The return type of all <span class="code">ejbCreate<METHOD>(...)</span>
|
||||
methods is not <span class="code">void</span>, because the return type must be
|
||||
The return type of all <span class="code">ejbCreate<METHOD>(...)</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">
|
||||
|
|
@ -96,11 +96,11 @@
|
|||
<span class="code">static</span>.
|
||||
</li>
|
||||
<li class="body">
|
||||
The return type of all <span class="code">ejbPostCreate<METHOD>(...)</span>
|
||||
The return type of all <span class="code">ejbPostCreate<METHOD>(...)</span>
|
||||
methods is <span class="code">void</span>.
|
||||
</li>
|
||||
<li class="body">
|
||||
For each <span class="code">ejbCreate<METHOD>(...)</span> method there is
|
||||
For each <span class="code">ejbCreate<METHOD>(...)</span> method there is
|
||||
a matching <span class="code">ejbPostCreate<METHOD>(...)</span> method.
|
||||
</li>
|
||||
</li>
|
||||
|
|
@ -109,7 +109,7 @@
|
|||
<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<METHOD>(...)</span>
|
||||
The throws clause of all <span class="code">ejbHome<METHOD>(...)</span>
|
||||
methods does not define the <span class="code">java.rmi.RemoteException</span>.
|
||||
</li>
|
||||
</ul>
|
||||
|
|
@ -125,8 +125,8 @@
|
|||
<span class="code">static</span>.
|
||||
</li>
|
||||
<li class="body">
|
||||
The return type of all <span class="code">ejbFind<METHOD>(...)</span>
|
||||
methods is not <span class="code">void</span>, because the return type must be
|
||||
The return type of all <span class="code">ejbFind<METHOD>(...)</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">
|
||||
|
|
@ -139,7 +139,7 @@
|
|||
</p>
|
||||
<ul>
|
||||
<li class="body">
|
||||
The throws clause of all <span class="code">ejbCreate<METHOD>(...)</span>
|
||||
The throws clause of all <span class="code">ejbCreate<METHOD>(...)</span>
|
||||
methods defines the <span class="code">javax.ejb.CreateException</span>.
|
||||
</li>
|
||||
<li class="body">
|
||||
|
|
@ -147,7 +147,7 @@
|
|||
<span class="code">public</span> and <span class="code">abstract</span>.
|
||||
</li>
|
||||
<li class="body">
|
||||
The throws clause of all <span class="code">ejbSelect<METHOD>(...)</span>
|
||||
The throws clause of all <span class="code">ejbSelect<METHOD>(...)</span>
|
||||
methods defines the <span class="code">javax.ejb.FinderException</span>.
|
||||
</li>
|
||||
</ul>
|
||||
|
|
@ -169,7 +169,7 @@
|
|||
</tr>
|
||||
</table>
|
||||
<p class="body">
|
||||
Reference: Enterprise JavaBeans™ Specification,Version 2.0, sections
|
||||
Reference: Enterprise JavaBeans™ Specification,Version 2.0, sections
|
||||
10.6 and 12.2.
|
||||
</p>
|
||||
<h4>Example</h4>
|
||||
|
|
@ -230,12 +230,12 @@
|
|||
</p>
|
||||
<ul>
|
||||
<li class="body">
|
||||
The return type of all <span class="code">create<METHOD>(...)</span>
|
||||
methods is not <span class="code">void</span>, because the return type must be
|
||||
The return type of all <span class="code">create<METHOD>(...)</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<METHOD>(...)</span>
|
||||
The throws clause of all <span class="code">create<METHOD>(...)</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>
|
||||
|
|
@ -342,12 +342,12 @@
|
|||
</p>
|
||||
<ul>
|
||||
<li class="body">
|
||||
The return type of all <span class="code">create<METHOD>(...)</span>
|
||||
methods is not <span class="code">void</span>, because the return type must be
|
||||
The return type of all <span class="code">create<METHOD>(...)</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<METHOD>(...)</span>
|
||||
The throws clause of all <span class="code">create<METHOD>(...)</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>
|
||||
|
|
@ -504,7 +504,7 @@
|
|||
<hr />
|
||||
<div><a href="index.html">Back to the Checkstyle Home Page</a></div>
|
||||
<p class="copyright">
|
||||
Copyright © 2002-2003 Oliver Burn. All rights Reserved.
|
||||
Copyright © 2002-2004 Oliver Burn. All rights Reserved.
|
||||
</p>
|
||||
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -515,7 +515,7 @@ convention of using a
|
|||
<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>,
|
||||
|
|
@ -530,7 +530,7 @@ convention of using 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>
|
||||
|
||||
|
|
@ -590,7 +590,7 @@ convention of using a
|
|||
<hr />
|
||||
<div><a href="index.html">Back to the Checkstyle Home Page</a></div>
|
||||
<p class="copyright">
|
||||
Copyright © 2002-2003 Oliver Burn. All rights Reserved.
|
||||
Copyright © 2002-2004 Oliver Burn. All rights Reserved.
|
||||
</p>
|
||||
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@
|
|||
<module name="BooleanExpressionComplexity">
|
||||
<property name="max" value="7"/>
|
||||
</module>
|
||||
|
||||
|
||||
</pre>
|
||||
|
||||
<h4>Package</h4>
|
||||
|
|
@ -139,7 +139,7 @@
|
|||
<module name="ClassDataAbstractionCoupling">
|
||||
<property name="max" value="5"/>
|
||||
</module>
|
||||
|
||||
|
||||
</pre>
|
||||
|
||||
<h4>Package</h4>
|
||||
|
|
@ -193,7 +193,7 @@
|
|||
<module name="ClassFanOutComplexity">
|
||||
<property name="max" value="10"/>
|
||||
</module>
|
||||
|
||||
|
||||
</pre>
|
||||
|
||||
<h4>Package</h4>
|
||||
|
|
@ -258,7 +258,7 @@ considered good, 5-7 ok, 8-10 consider re-factoring, and 11+ re-factor now!
|
|||
<module name="CyclomaticComplexity">
|
||||
<property name="max" value="7"/>
|
||||
</module>
|
||||
|
||||
|
||||
</pre>
|
||||
|
||||
<h4>Package</h4>
|
||||
|
|
@ -320,7 +320,7 @@ considered good, 5-7 ok, 8-10 consider re-factoring, and 11+ re-factor now!
|
|||
<module name="NPathComplexity">
|
||||
<property name="max" value="20"/>
|
||||
</module>
|
||||
|
||||
|
||||
</pre>
|
||||
|
||||
<h4>Package</h4>
|
||||
|
|
@ -339,7 +339,7 @@ considered good, 5-7 ok, 8-10 consider re-factoring, and 11+ re-factor now!
|
|||
<hr />
|
||||
<div><a href="index.html">Back to the Checkstyle Home Page</a></div>
|
||||
<p class="copyright">
|
||||
Copyright © 2002-2003 Oliver Burn. All rights Reserved.
|
||||
Copyright © 2002-2004 Oliver Burn. All rights Reserved.
|
||||
</p>
|
||||
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -62,11 +62,11 @@
|
|||
|
||||
<!-- --> <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
|
||||
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
|
||||
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>
|
||||
|
|
@ -98,7 +98,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td>message</td>
|
||||
<td>message which is used to notify about violations,
|
||||
<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">""</span>(empty)</td>
|
||||
|
|
@ -190,8 +190,8 @@
|
|||
</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
|
||||
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>
|
||||
|
|
@ -211,8 +211,8 @@
|
|||
</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
|
||||
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>
|
||||
|
|
@ -347,30 +347,30 @@
|
|||
<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">'
|
||||
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">
|
||||
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
|
||||
<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">
|
||||
<module name="UpperEll"/>
|
||||
|
|
@ -378,12 +378,12 @@ like <span class="code">1</span>.
|
|||
<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>
|
||||
|
|
@ -880,7 +880,7 @@ like <span class="code">1</span>.
|
|||
<hr />
|
||||
<div><a href="index.html">Back to the Checkstyle Home Page</a></div>
|
||||
<p class="copyright">
|
||||
Copyright © 2002-2003 Oliver Burn. All rights Reserved.
|
||||
Copyright © 2002-2004 Oliver Burn. All rights Reserved.
|
||||
</p>
|
||||
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ Language specification, section 9.3</a>).
|
|||
<hr />
|
||||
<div><a href="index.html">Back to the Checkstyle Home Page</a></div>
|
||||
<p class="copyright">
|
||||
Copyright © 2002-2003 Oliver Burn. All rights Reserved.
|
||||
Copyright © 2002-2004 Oliver Burn. All rights Reserved.
|
||||
</p>
|
||||
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -19,9 +19,9 @@
|
|||
<!-- 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
|
||||
Each of these naming modules validates identifiers for particular code elements. Valid
|
||||
identifiers for a naming module are specified by its <span class="code">
|
||||
format</span> property. The value of <span class="code">format</span> is a <a href="http://jakarta.apache.org/regexp/">regular
|
||||
expression</a> for valid identifiers.
|
||||
This is an example of a configuration of the <span class="code">MemberName</span> module to
|
||||
ensure that member identifiers begin with <span class="code">'m'</span>,
|
||||
|
|
@ -52,7 +52,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td><span class="code">ConstantName</span></td>
|
||||
<td>constants (<span class="code">static</span>, <span class="code">
|
||||
<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>
|
||||
|
|
@ -103,10 +103,10 @@
|
|||
<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
|
||||
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
|
||||
|
|
@ -121,10 +121,10 @@
|
|||
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>.
|
||||
<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:
|
||||
followed by letters and digits:
|
||||
<pre class="body">
|
||||
<module name="LocalVariableName">
|
||||
<property name="format" value="^e[a-zA-Z0-9]*$"/>
|
||||
|
|
@ -136,9 +136,9 @@
|
|||
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>.
|
||||
<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:
|
||||
interface names begin with <span class="code">"I_"</span>, followed by letters and digits:
|
||||
<pre class="body">
|
||||
<module name="TypeName">
|
||||
<property name="format" value="^I_[a-zA-Z0-9]*$"/>
|
||||
|
|
@ -185,7 +185,7 @@
|
|||
<hr />
|
||||
<div><a href="index.html">Back to the Checkstyle Home Page</a></div>
|
||||
<p class="copyright">
|
||||
Copyright © 2002-2003 Oliver Burn. All rights Reserved.
|
||||
Copyright © 2002-2004 Oliver Burn. All rights Reserved.
|
||||
</p>
|
||||
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ type is <a href="property_types.html#string">string</a> and defaults to an
|
|||
empty string.</p>
|
||||
|
||||
<hr/>
|
||||
<p class="copyright">Copyright © 2002-2003 Oliver Burn. All rights Reserved.</p>
|
||||
<p class="copyright">Copyright © 2002-2004 Oliver Burn. All rights Reserved.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@
|
|||
<property name="max" value="20"/>
|
||||
<property name="tokens" value="CTOR_DEF,METHOD_DEF"/>
|
||||
</module>
|
||||
|
||||
|
||||
</pre>
|
||||
|
||||
<h4>Package</h4>
|
||||
|
|
@ -123,8 +123,8 @@
|
|||
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
|
||||
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>
|
||||
|
||||
|
|
@ -169,8 +169,8 @@
|
|||
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
|
||||
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>
|
||||
|
||||
|
|
@ -207,7 +207,7 @@
|
|||
</module>
|
||||
</pre>
|
||||
<p class="body">
|
||||
To configure the check to ignore lines that begin with " * ", followed
|
||||
To configure the check to ignore lines that begin with " * ", followed
|
||||
by just one word, such as within a Javadoc comment:
|
||||
</p>
|
||||
<pre class="body">
|
||||
|
|
@ -219,18 +219,18 @@
|
|||
<h4>Notes</h4>
|
||||
<ul class="body">
|
||||
<li>
|
||||
The calculation of the length of a line takes into account the number of expanded spaces
|
||||
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
|
||||
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
|
||||
<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">ignorePattern</span> to
|
||||
<span class="code">^import</span> and achieve the same effect.
|
||||
</li>
|
||||
</ul>
|
||||
|
|
@ -250,8 +250,8 @@
|
|||
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
|
||||
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>
|
||||
|
||||
|
|
@ -448,7 +448,7 @@
|
|||
<hr />
|
||||
<div><a href="index.html">Back to the Checkstyle Home Page</a></div>
|
||||
<p class="copyright">
|
||||
Copyright © 2002-2003 Oliver Burn. All rights Reserved.
|
||||
Copyright © 2002-2004 Oliver Burn. All rights Reserved.
|
||||
</p>
|
||||
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@
|
|||
</td>
|
||||
<!--Content-->
|
||||
<td class="content" valign="top" align="left">
|
||||
|
||||
|
||||
<a name="OneMethodPrivateField"></a> <h2>OneMethodPrivateField</h2> <h4>Description</h4>
|
||||
|
||||
<p class="body">
|
||||
|
|
@ -321,7 +321,7 @@
|
|||
<hr />
|
||||
<div><a href="index.html">Back to the Checkstyle Home Page</a></div>
|
||||
<p class="copyright">
|
||||
Copyright © 2002-2003 Oliver Burn. All rights Reserved.
|
||||
Copyright © 2002-2004 Oliver Burn. All rights Reserved.
|
||||
</p>
|
||||
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@
|
|||
</td>
|
||||
<!--Content-->
|
||||
<td class="content" valign="top" align="left">
|
||||
|
||||
|
||||
<a name="EmptyForInitializerPad"></a> <h2>EmptyForInitializerPad</h2> <h4>Description</h4>
|
||||
|
||||
<p class="body">
|
||||
|
|
@ -177,8 +177,8 @@ for (Iterator foo = very.long.line.iterator();
|
|||
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,
|
||||
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>
|
||||
|
|
@ -260,9 +260,9 @@ for (Iterator foo = very.long.line.iterator();
|
|||
<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,
|
||||
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>
|
||||
|
|
@ -349,9 +349,9 @@ for (Iterator foo = very.long.line.iterator();
|
|||
<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,
|
||||
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>
|
||||
|
|
@ -566,7 +566,7 @@ for (Iterator foo = very.long.line.iterator();
|
|||
<module name="OperatorWrap"/>
|
||||
</pre>
|
||||
<p class="body">
|
||||
To configure the check for the assignment operator, <span class="code">=</span>,
|
||||
To configure the check for the assignment operator, <span class="code">=</span>,
|
||||
at the end of a line:
|
||||
</p>
|
||||
<pre class="body">
|
||||
|
|
@ -589,8 +589,8 @@ for (Iterator foo = very.long.line.iterator();
|
|||
<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
|
||||
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>
|
||||
|
|
@ -644,7 +644,7 @@ for (Iterator foo = very.long.line.iterator();
|
|||
<module name="ParenPad"/>
|
||||
</pre>
|
||||
<p class="body">
|
||||
To configure the check to require spaces for the parentheses of constructor,
|
||||
To configure the check to require spaces for the parentheses of constructor,
|
||||
method, and super constructor calls:
|
||||
</p>
|
||||
<pre class="body">
|
||||
|
|
@ -672,7 +672,7 @@ for (Iterator foo = very.long.line.iterator();
|
|||
<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">
|
||||
|
|
@ -734,7 +734,7 @@ for (Iterator foo = very.long.line.iterator();
|
|||
<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
|
||||
Checks that there are no tab characters (<span class="code">'\t'</span>) in the
|
||||
source code.
|
||||
</p>
|
||||
<p class="body">
|
||||
|
|
@ -742,12 +742,12 @@ for (Iterator foo = very.long.line.iterator();
|
|||
</p>
|
||||
<ul class="body">
|
||||
<li>
|
||||
Developers should not need to configure the tab width of their text editors in
|
||||
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
|
||||
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>
|
||||
|
|
@ -973,7 +973,7 @@ for (Iterator foo = very.long.line.iterator();
|
|||
<hr />
|
||||
<div><a href="index.html">Back to the Checkstyle Home Page</a></div>
|
||||
<p class="copyright">
|
||||
Copyright © 2002-2003 Oliver Burn. All rights Reserved.
|
||||
Copyright © 2002-2004 Oliver Burn. All rights Reserved.
|
||||
</p>
|
||||
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -132,5 +132,5 @@
|
|||
</table>
|
||||
<hr/>
|
||||
<div><a href="index.html">Back to the Checkstyle Home Page</a></div>
|
||||
<p class="copyright">Copyright © 2002-2003 Oliver Burn. All rights Reserved.</p>
|
||||
<p class="copyright">Copyright © 2002-2004 Oliver Burn. All rights Reserved.</p>
|
||||
</body> </html>
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ href="http://www.intellij.org/twiki/bin/view/Main/JetStylePlugin">http://www.int
|
|||
Checkstyle with
|
||||
<a href="http://www.borland.com/jbuilder/">Borland JBuilder</a>.
|
||||
It is available via the <a
|
||||
href="http://sourceforge.net/projects/jbcheckstyle-pg/">JBCS
|
||||
href="http://sourceforge.net/projects/jbcheckstyle-pg/">JBCS
|
||||
Sourceforge Project Page</a>.
|
||||
</li>
|
||||
|
||||
|
|
@ -248,6 +248,6 @@ also available.
|
|||
</tr>
|
||||
</table>
|
||||
<hr/>
|
||||
<p class="copyright">Copyright © 2001-2003 Oliver Burn. All rights Reserved.</p>
|
||||
<p class="copyright">Copyright © 2001-2004 Oliver Burn. All rights Reserved.</p>
|
||||
|
||||
</body> </html>
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ names such as <span class="code">UnusedLocalVariable</span>.
|
|||
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
|
||||
For example, this is a command to run Checkstyle with a configuration
|
||||
that contains optional checks:
|
||||
</p>
|
||||
<pre>
|
||||
|
|
@ -72,6 +72,6 @@ Please consult <a href="cmdline.html">Command Line</a> and
|
|||
|
||||
<hr />
|
||||
<div><a href="index.html">Back to the Checkstyle Home Page</a></div>
|
||||
<p class="copyright">Copyright © 2002-2003 Oliver Burn. All rights Reserved.</p>
|
||||
<p class="copyright">Copyright © 2002-2004 Oliver Burn. All rights Reserved.</p>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -294,7 +294,7 @@ or mixed persistence:</p>
|
|||
|
||||
<hr />
|
||||
<div><a href="index.html">Back to the Checkstyle Home Page</a></div>
|
||||
<p class="copyright">Copyright © 2002-2003 Oliver Burn. All rights Reserved.</p>
|
||||
<p class="copyright">Copyright © 2002-2004 Oliver Burn. All rights Reserved.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -981,5 +981,5 @@
|
|||
</table>
|
||||
<hr />
|
||||
<div><a href="index.html">Back to the Checkstyle Home Page</a></div>
|
||||
<p class="copyright">Copyright © 2002-2003 Oliver Burn. All rights Reserved.</p>
|
||||
<p class="copyright">Copyright © 2002-2004 Oliver Burn. All rights Reserved.</p>
|
||||
</body> </html>
|
||||
|
|
|
|||
|
|
@ -588,5 +588,5 @@
|
|||
</table>
|
||||
<hr/>
|
||||
<div><a href="index.html">Back to the Checkstyle Home Page</a></div>
|
||||
<p class="copyright">Copyright © 2002-2003 Oliver Burn. All rights Reserved.</p>
|
||||
<p class="copyright">Copyright © 2002-2004 Oliver Burn. All rights Reserved.</p>
|
||||
</body> </html>
|
||||
|
|
|
|||
|
|
@ -55,10 +55,10 @@
|
|||
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>.
|
||||
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>
|
||||
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"/>
|
||||
|
|
@ -98,7 +98,7 @@ public class FilesFilter
|
|||
{
|
||||
setFiles("^$");
|
||||
}
|
||||
|
||||
|
||||
public boolean accept(AuditEvent aEvent)
|
||||
{
|
||||
final String fileName = aEvent.getFileName();
|
||||
|
|
@ -117,13 +117,13 @@ public class FilesFilter
|
|||
<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>
|
||||
<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 "Generated", include the following module in the
|
||||
configuration file:
|
||||
</p>
|
||||
|
||||
<pre class="body">
|
||||
<pre class="body">
|
||||
<module name="com.mycompany.filters.FilesFilter">
|
||||
<property name="files" value="Generated"/>
|
||||
</module>
|
||||
|
|
@ -131,12 +131,12 @@ public class FilesFilter
|
|||
|
||||
<a name="huh"></a> <h2>Huh? I can't figure it out!</h2>
|
||||
<p class="body">
|
||||
That'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 "I want
|
||||
to write a filter but I don't know how, can you help me?". Tell us
|
||||
what you are trying to do (the purpose of the filter), what you have
|
||||
That'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 "I want
|
||||
to write a filter but I don't know how, can you help me?". 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>
|
||||
|
||||
|
|
@ -144,8 +144,8 @@ public class FilesFilter
|
|||
<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
|
||||
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>
|
||||
|
|
@ -158,7 +158,7 @@ public class FilesFilter
|
|||
<a href="index.html">Back to the Checkstyle Home Page</a>
|
||||
</div>
|
||||
<p class="copyright">
|
||||
Copyright © 2002-2003 Oliver Burn. All rights Reserved.
|
||||
Copyright © 2002-2004 Oliver Burn. All rights Reserved.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -51,42 +51,42 @@
|
|||
<!--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.
|
||||
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>
|
||||
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
|
||||
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
|
||||
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>
|
||||
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"/>
|
||||
|
|
@ -94,17 +94,17 @@
|
|||
<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>
|
||||
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
|
||||
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>,
|
||||
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>
|
||||
|
|
@ -144,7 +144,7 @@ public class VerboseListener
|
|||
mTotalErrors = 0;
|
||||
mWriter.println("Audit started.");
|
||||
}
|
||||
|
||||
|
||||
public void auditFinished(AuditEvent aEvt)
|
||||
{
|
||||
mWriter.println("Audit finished. Total errors: " + mTotalErrors);
|
||||
|
|
@ -197,10 +197,10 @@ public class VerboseListener
|
|||
}
|
||||
</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>
|
||||
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>
|
||||
|
||||
|
|
@ -209,20 +209,20 @@ public class VerboseListener
|
|||
<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>
|
||||
<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 "audit.txt", include the following module in the
|
||||
configuration file:
|
||||
</p>
|
||||
|
||||
<pre class="body">
|
||||
<pre class="body">
|
||||
<module name="com.mycompany.listeners.VerboseListener">
|
||||
<property name="file" value="audit.txt"/>
|
||||
</module>
|
||||
</pre>
|
||||
|
||||
<p class="body">
|
||||
Here is a truncated example of audit output from a <span class="code">
|
||||
Here is a truncated example of audit output from a <span class="code">
|
||||
VerboseListener</span>:
|
||||
</p>
|
||||
|
||||
|
|
@ -240,45 +240,45 @@ public class VerboseListener
|
|||
|
||||
<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ç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">"Java
|
||||
Development with Ant"</a> by Eric Hatcher and Steve Loughran, an excellent
|
||||
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ç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">"Java
|
||||
Development with Ant"</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
|
||||
<a href="http://jakarta.apache.org/commons/logging.html">Jakarata Commons
|
||||
Logging</a> provides a faç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
|
||||
<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">
|
||||
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
|
||||
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>
|
||||
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>
|
||||
|
|
@ -293,7 +293,7 @@ public class VerboseListener
|
|||
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>
|
||||
Running a Checkstyle audit with a <span class="code">CommonsLoggingListener</span>
|
||||
yields this (abbreviated) output:
|
||||
</p>
|
||||
<pre>
|
||||
|
|
@ -317,13 +317,13 @@ public class VerboseListener
|
|||
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
|
||||
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>,
|
||||
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:
|
||||
|
|
@ -336,12 +336,12 @@ public class VerboseListener
|
|||
</pre>
|
||||
<a name="huh"></a> <h2>Huh? I can't figure it out!</h2>
|
||||
<p class="body">
|
||||
That'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 "I want
|
||||
to write a listener but I don't know how, can you help me?". Tell us
|
||||
what you are trying to do (the purpose of the listener), what you have
|
||||
That'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 "I want
|
||||
to write a listener but I don't know how, can you help me?". 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>
|
||||
|
||||
|
|
@ -349,8 +349,8 @@ public class VerboseListener
|
|||
<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
|
||||
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>
|
||||
|
|
@ -363,7 +363,7 @@ public class VerboseListener
|
|||
<a href="index.html">Back to the Checkstyle Home Page</a>
|
||||
</div>
|
||||
<p class="copyright">
|
||||
Copyright © 2002-2003 Oliver Burn. All rights Reserved.
|
||||
Copyright © 2002-2004 Oliver Burn. All rights Reserved.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
Loading…
Reference in New Issue