diff --git a/docs/anttask.html b/docs/anttask.html index 9242b58a5..d2721dccb 100644 --- a/docs/anttask.html +++ b/docs/anttask.html @@ -271,6 +271,6 @@ provide a package names file
- + diff --git a/docs/cmdline.html b/docs/cmdline.html index 5ee18e2dc..da6e5f359 100644 --- a/docs/cmdline.html +++ b/docs/cmdline.html @@ -144,7 +144,7 @@ provide a package names file

Tip

- 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 -jar option. An example would be:

@@ -156,6 +156,6 @@ provide a package names file
Back to the Checkstyle Home Page
- + diff --git a/docs/config.html b/docs/config.html index fb95b8988..0406d9f5a 100644 --- a/docs/config.html +++ b/docs/config.html @@ -826,7 +826,7 @@
Back to the Checkstyle Home Page
diff --git a/docs/config_blocks.html b/docs/config_blocks.html index 847795cec..ba28c3b94 100644 --- a/docs/config_blocks.html +++ b/docs/config_blocks.html @@ -259,7 +259,7 @@

RightCurly

Description

Checks the placement of right curly braces ('}') for - else, try, and catch + else, try, and catch tokens. The policy to verify is specified using property option.

@@ -430,7 +430,7 @@ switch (a)
Back to the Checkstyle Home Page
diff --git a/docs/config_coding.html b/docs/config_coding.html index 67a10c6fb..59c619663 100644 --- a/docs/config_coding.html +++ b/docs/config_coding.html @@ -1620,7 +1620,7 @@ return !valid();
Back to the Checkstyle Home Page
diff --git a/docs/config_design.html b/docs/config_design.html index b3c339d90..4540fc64d 100644 --- a/docs/config_design.html +++ b/docs/config_design.html @@ -408,7 +408,7 @@ public class StringUtils // not final to allow subclassing
Back to the Checkstyle Home Page
diff --git a/docs/config_duplicates.html b/docs/config_duplicates.html index 17474f240..d9f4279ba 100644 --- a/docs/config_duplicates.html +++ b/docs/config_duplicates.html @@ -141,7 +141,7 @@ Checkstyle plugins for duplicate code detection:
Back to the Checkstyle Home Page
diff --git a/docs/config_header.html b/docs/config_header.html index 81413694c..3ef89759f 100644 --- a/docs/config_header.html +++ b/docs/config_header.html @@ -39,9 +39,9 @@ headerFile specifies a file that contains the required header.

- Property ignoreLines 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 ignoreLines 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:

@@ -52,7 +52,7 @@ line 4: // Copyright (C) 2002  Oliver Burn
 line 5: ////////////////////////////////////////////////////////////////////
       

- 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 ignoreLines to 4.

@@ -80,7 +80,7 @@ line 5: ////////////////////////////////////////////////////////////////////

Example

- To configure the check to use header file "java.header" + To configure the check to use header file "java.header" and ignore lines 2, 3, and 4:

@@ -100,12 +100,12 @@ line 5: ////////////////////////////////////////////////////////////////////

RegexpHeader

Description

- Checks the header of a source file against a header file that contains a regular + Checks the header of a source file against a header file that contains a regular expression for each line of the source header.

- Rationale: In some projects checking against a fixed header - is not sufficient, e.g. the header might require a copyright line where the year + Rationale: In some projects checking against a fixed header + is not sufficient, e.g. the header might require a copyright line where the year information is not static.

@@ -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: ^ \*/


Back to the Checkstyle Home Page
diff --git a/docs/config_import.html b/docs/config_import.html index f67249a4a..e2b37b67c 100644 --- a/docs/config_import.html +++ b/docs/config_import.html @@ -91,9 +91,9 @@

Description

- Checks for imports from a set of illegal packages. By default, the check rejects - all sun.* packages since programs that contain direct - calls to the sun.* packages are not + Checks for imports from a set of illegal packages. By default, the check rejects + all sun.* packages since programs that contain direct + calls to the sun.* packages are not 100% Pure Java. To reject other packages, set property illegalPkgs to a list of the illegal packages.

@@ -121,7 +121,7 @@ <module name="IllegalImport"/>

- To configure the check so that it rejects packages java.io.* + To configure the check so that it rejects packages java.io.* and java.sql.*:

@@ -139,16 +139,16 @@
       

RedundantImport

Description

- Checks for redundant import statements. An import statement is considered + Checks for redundant import statements. An import statement is considered redundant if:

Package

@@ -139,7 +139,7 @@ <module name="ClassDataAbstractionCoupling"> <property name="max" value="5"/> </module> - +

Package

@@ -193,7 +193,7 @@ <module name="ClassFanOutComplexity"> <property name="max" value="10"/> </module> - +

Package

@@ -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> - +

Package

@@ -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> - +

Package

@@ -339,7 +339,7 @@ considered good, 5-7 ok, 8-10 consider re-factoring, and 11+ re-factor now!
Back to the Checkstyle Home Page
diff --git a/docs/config_misc.html b/docs/config_misc.html index 64e2c8010..90d62430d 100644 --- a/docs/config_misc.html +++ b/docs/config_misc.html @@ -62,11 +62,11 @@

GenericIllegalRegexp

Description

- 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.

- 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 ex.printStacktrace(), System.out.println(), System.exit(), etc.

@@ -98,7 +98,7 @@ message - message which is used to notify about violations, + message which is used to notify about violations, if empty then default(hard-coded) message is used. String ""(empty) @@ -190,8 +190,8 @@

TodoComment

Description

- A check for TODO: comments. Actually it is a generic regular - expression matcher on Java comments. To check for other patterns in Java + A check for TODO: comments. Actually it is a generic regular + expression matcher on Java comments. To check for other patterns in Java comments, set property format.

Properties

@@ -211,8 +211,8 @@

Notes

- Using TODO: comments is a great way to keep track of - tasks that need to be done. Having them reported by Checkstyle makes it very + Using TODO: 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.

Examples

@@ -347,30 +347,30 @@

Package

com.puppycrawl.tools.checkstyle.checks - +

Parent Module

TreeWalker - +

UpperEll

Description

- Checks that long constants are defined with an upper ell. That is ' + Checks that long constants are defined with an upper ell. That is ' L' and -not 'l'. This is in accordance to the Java Language -Specification, +not 'l'. This is in accordance to the Java Language +Specification, Section 3.10.1.

-

Rationale: The letter l looks a lot +

Rationale: The letter l looks a lot like 1.

Examples

To configure the check: - +

 <module name="UpperEll"/>
@@ -378,12 +378,12 @@ like 1.
       

Package

com.puppycrawl.tools.checkstyle.checks - +

Parent Module

TreeWalker - +

ArrayTypeStyle

Description

@@ -880,7 +880,7 @@ like 1.
Back to the Checkstyle Home Page
diff --git a/docs/config_modifiers.html b/docs/config_modifiers.html index be0da9b5b..2d29a6613 100644 --- a/docs/config_modifiers.html +++ b/docs/config_modifiers.html @@ -177,7 +177,7 @@ Language specification, section 9.3).
Back to the Checkstyle Home Page
diff --git a/docs/config_naming.html b/docs/config_naming.html index 4d0359d7b..2757cb834 100644 --- a/docs/config_naming.html +++ b/docs/config_naming.html @@ -19,9 +19,9 @@

Overview

- Each of these naming modules validates identifiers for particular code elements. Valid - identifiers for a naming module are specified by its - format property. The value of format is a regular + Each of these naming modules validates identifiers for particular code elements. Valid + identifiers for a naming module are specified by its + format property. The value of format is a regular expression for valid identifiers. This is an example of a configuration of the MemberName module to ensure that member identifiers begin with 'm', @@ -52,7 +52,7 @@ ConstantName - constants (static, + constants (static, final fields) ^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$ @@ -103,10 +103,10 @@

diff --git a/docs/writinglisteners.html b/docs/writinglisteners.html index 92477622f..94653eab3 100644 --- a/docs/writinglisteners.html +++ b/docs/writinglisteners.html @@ -51,42 +51,42 @@

Overview

- A Checkstyle listener monitors the progress of a Checker - during the audit of files. The Checker 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 Checker + during the audit of files. The Checker 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 - Checker. An audit always adds one of the distribution listeners, DefaultLogger - or XMLLogger, - to report events. A DefaultLogger produces simple text - output for the events it receives, and a XMLLogger + Checker. An audit always adds one of the distribution listeners, DefaultLogger + or XMLLogger, + to report events. A DefaultLogger produces simple text + output for the events it receives, and a XMLLogger produces an XML document for its events.

Listeners DefaultLogger and - XMLLogger 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 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.

- A listener is an implementation of the AuditListener - interface. During an audit, a Checker informs its - attached AuditListeners of six kinds of events: audit + A listener is an implementation of the AuditListener + interface. During an audit, a Checker informs its + attached AuditListeners of six kinds of events: audit started/ended, file started/ended, and logging of an error/exception.

- An audit passes an event to a listener as an AuditEvent. - A file-related AuditEvent contains the name of that - file. An AuditEvent for error logging has a message, a - severity level, a message source such as the name of a Check, - and file line and column numbers that may be relevant to the error. The - notification of an exception to a AuditListener - includes an error AuditEvent and the details of the - exception. Here is a UML diagram for classes AuditListener + An audit passes an event to a listener as an AuditEvent. + A file-related AuditEvent contains the name of that + file. An AuditEvent for error logging has a message, a + severity level, a message source such as the name of a Check, + and file line and column numbers that may be relevant to the error. The + notification of an exception to a AuditListener + includes an error AuditEvent and the details of the + exception. Here is a UML diagram for classes AuditListener and AuditEvent.

AuditListener UML diagram @@ -94,17 +94,17 @@

Writing Listeners

- A custom listener is an implementation of the AuditListener + A custom listener is an implementation of the AuditListener interface. If the listener has properties that can be set from a configuration, the listener must extend AutomaticBean. An AutomaticBean uses JavaBean introspection to set JavaBean properties.

- 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 System.out. In order to enable the specification of output to a file - through property file, + through property file, the class extends AutomaticBean and defines method setFile(String).

@@ -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 }

- A listener that filters error events could perform the filtering in methods - addError and addException. As further examples - of listeners, CommonsLoggingListener - reports its events through the Commons Logging API, and MailLogger + A listener that filters error events could perform the filtering in methods + addError and addException. As further examples + of listeners, CommonsLoggingListener + reports its events through the Commons Logging API, and MailLogger e-mails the audit report of a DefaultLogger.

@@ -209,20 +209,20 @@ public class VerboseListener

To incorporate a custom listener in the set of listeners for a Checker, include a module element for the listener in the - configuration file. For example, to configure a Checker + configuration file. For example, to configure a Checker so that it uses custom listener VerboseListener to print audit messages to a file named "audit.txt", include the following module in the configuration file:

-
     
+      
     <module name="com.mycompany.listeners.VerboseListener">
         <property name="file" value="audit.txt"/>
     </module>
       

- Here is a truncated example of audit output from a + Here is a truncated example of audit output from a VerboseListener:

@@ -240,45 +240,45 @@ public class VerboseListener

Examples

- This section describes two examples based on ANT listeners. The first listener, - CommonsLoggingListener, hands off events to the Jakarata - Commons Logging façade and the second, MailLogger, - sends a report of an audit via e-mail. The discussion of these examples and how - to use them is derived from material in "Java - Development with Ant" by Eric Hatcher and Steve Loughran, an excellent + This section describes two examples based on ANT listeners. The first listener, + CommonsLoggingListener, hands off events to the Jakarata + Commons Logging façade and the second, MailLogger, + sends a report of an audit via e-mail. The discussion of these examples and how + to use them is derived from material in "Java + Development with Ant" by Eric Hatcher and Steve Loughran, an excellent ANT book.

CommonsLoggingListener

- Jakarata Commons + Jakarata Commons Logging provides a façade for logging tools log4j, - Avalon LogKit, - J2SE 1.4, and others. Checkstyle listener - CommonsLoggingListener responds to an AuditEvent by handing it off to the + Avalon LogKit, + J2SE 1.4, and others. Checkstyle listener + CommonsLoggingListener responds to an AuditEvent by handing it off to the current Commons Logging Log.

- The source code for CommonsLoggingListener is in - distribution directory contrib/examples/listeners. - Notice that each AuditListener method that receives an - AuditEvent calls a method for the Commons Logging log level corresponding - to the Checkstyle SeverityLevel of the + The source code for CommonsLoggingListener is in + distribution directory contrib/examples/listeners. + Notice that each AuditListener method that receives an + AuditEvent calls a method for the Commons Logging log level corresponding + to the Checkstyle SeverityLevel of the AuditEvent.

- The easiest way to use CommonsLoggingListener is to - include checkstyle-all-@CHECKSTYLE_VERSION@.jar in - the classpath because that jar file contains all the Commons Logging classes. - The default Log under J2SE 1.4 is wrapper class Jdk14Logger. - Under earlier Java versions, the default Log is a simple wrapper class, SimpleLog. - 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 CommonsLoggingListener is to + include checkstyle-all-@CHECKSTYLE_VERSION@.jar in + the classpath because that jar file contains all the Commons Logging classes. + The default Log under J2SE 1.4 is wrapper class Jdk14Logger. + Under earlier Java versions, the default Log is a simple wrapper class, SimpleLog. + 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.

- Logging configuration details for Jakarta Commons Logging are in the documentation. - As a simple example, assume that log4j.jar is in - the classpath and the following log4j.properties + Logging configuration details for Jakarta Commons Logging are in the documentation. + As a simple example, assume that log4j.jar is in + the classpath and the following log4j.properties file is in the current directory:

@@ -293,7 +293,7 @@ public class VerboseListener
       log4j.appender.A1.layout.ConversionPattern=%-5p %c %x- %m%n
     

- Running a Checkstyle audit with a CommonsLoggingListener + Running a Checkstyle audit with a CommonsLoggingListener yields this (abbreviated) output:

@@ -317,13 +317,13 @@ public class VerboseListener
       from environment properties that can be read from a properties file.
       

- The source code for CommonsLoggingListener is in + The source code for CommonsLoggingListener is in distribution directory contrib/examples/listeners. This implementation uses the JavaMail API as the mail system, and you must include appropriate jar files in the classpath.

- As an example of using MailLogger, + As an example of using MailLogger, set system property -DMailLogger.properties.file=MailLogger.properties, so that MailLogger reads message parameters from file MailLogger.properties of the current directory: @@ -336,12 +336,12 @@ public class VerboseListener

Huh? I can't figure it out!

- 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.

@@ -349,8 +349,8 @@ public class VerboseListener

We need your help to keep improving Checkstyle. - Whenever you write a listener that you think is generally useful, please - consider contributing it to the Checkstyle + Whenever you write a listener that you think is generally useful, please + consider contributing it to the Checkstyle community and submit it for inclusion in the next release of Checkstyle.

@@ -363,7 +363,7 @@ public class VerboseListener Back to the Checkstyle Home Page