ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <DDevie...@lgc.com>
Subject RE: Checkstyle 2.3 released
Date Tue, 09 Jul 2002 22:07:31 GMT
For whoever wants to try out <checkstyle> easily, here's how I set it up in
Ant 1.4.1 (Ant 1.5 would work the same I'm sure) this afternoon. Ran it on
my small project (~ 300 files), and it found over 13,000 errors :-(
Hopefully someone will find this useful. --DD

Added a build/tools/checkstyle directory to CVS, with the following files
inside it:

checkstyle-all-2.3.jar		The self-contained JAR.
checkstyle.properties		My custom config annotated with help.
checkstyle-frames.xsl		Stylesheet to convert to HTML.
checkstyle-noframes.xsl		(The -frames one seems broken)
checkstyle-simple.xsl

Then added the 'checkstyle' target below in my build.xml, modeled after the
checkstyle documentation of its Ant task. Note that you doesn't need to copy
the JAR in $ANT_HOME\lib (also added the removal of the checkstyle products
in my 'clean' target): 

  <target name="checkstyle">

    <property name="checkstyle.base"
              value="${basedir}/build/tools/checkstyle/checkstyle" />

    <taskdef resource="checkstyletask.properties"
             classpath="${checkstyle.base}-all-2.3.jar" />

    <delete file="${checkstyle.base}-results.xml" quiet="true" />
    <delete file="${checkstyle.base}-results.html" quiet="true" />

    <checkstyle basedir="${basedir}/src"
                properties="${checkstyle.base}.properties"
                cacheFile="${checkstyle.base}-results.db"
                failOnViolation="false">
      <fileset dir="src">
        <include name="**/*.java" />
        <exclude name="**/test/*Test.java" />
      </fileset>

      <!-- Choice of 'plain' text or 'xml' formatter -->
      <formatter type="xml"
                 tofile="${checkstyle.base}-results.xml" />
    </checkstyle>

    <style in="${checkstyle.base}-results.xml"
           out="${checkstyle.base}-results.html"
           style="${checkstyle.base}-noframes.xsl" />

  </target><!-- checkstyle -->

Here's the checkstyle.properties, which is convenient to edit since the
online doc of the different properties has been copied next to each possible
property. I haven't figured out how to configure it exactly the way I want,
as will be obvious to some I'm sure:

# Specifies the policy of where to put the left brace '{'
# for type declarations.
# The legal values are: ignore, eol, no, nlow.
# Defaults to "eol". 
checkstyle.lcurly.type = eol

# Specifies the policy of where to put the left brace '{'
# for method declarations.
# The legal values are: ignore, eol, no, nlow.
# Defaults to "eol". 
checkstyle.lcurly.method = eol

# Specifies the policy of where to put the left brace '{'
# for other declarations.
# The legal values are: ignore, eol, no, nlow.
# The legal values are defined here.
# Defaults to "eol". 
checkstyle.lcurly.other = ignore

# Specifies the policy of where to put the right brace '}'.
# The keywords covered are defined here.
# The legal values are: ignore, same, alone.
# Defaults to "same". 
checkstyle.rcurly = alone

# Specifies the policy of how to pad parenthesises.
# The legal values are: ignore, nospace.
# Defaults to "nospace". 
checkstyle.paren.pad = nospace

# Specifies the policy of how check try blocks.
# The legal values are: ignore, text, stmt.
# Defaults to "stmt". 
checkstyle.block.try = stmt

# Specifies the policy of how check catch blocks.
# The legal values are defined here.
# Defaults to "text". 
checkstyle.block.catch = text

# Specifies the policy of how check finally blocks.
# The legal values are defined here.
# Defaults to "text". 
checkstyle.block.finally = stmt

# Specifies the policy of how to wrap on operators.
# The legal values are: ignore, nl.
# Defaults to "nl". 
checkstyle.wrap.operator = ignore

# Indicates whether to allow protected data.
# Defaults to "no". 
checkstyle.allow.protected = yes

# Indicates whether to allow tabs.
# Defaults to "no". 
checkstyle.allow.tabs = no

# Indicates whether to allow package visible data.
# Defaults to "no". 
checkstyle.allow.package = yes

# Indicates whether to allow not @author tag to be defined
# for class and interface Javadoc comments.
# Defaults to "no". 
checkstyle.allow.noauthor = no

# Specifies the maximum line length.
# Default value is defined here. 
checkstyle.maxlinelen = 80

# The distance between tab stops, used in line number and column
calculations.
# Default value is "8". 
checkstyle.tab.width = 2

# Specifies a regular expression for lines to ignore
# in maximum line length checks.
# Defaults to "^$". 
checkstyle.ignore.maxlinelen = \/\/@@$

# Specifies whether to ignore the maximum line length for import statements.
# Defaults to "no". 
checkstyle.ignore.importlength = yes

# Specifies the maximum method length.
# Default value is defined here. 
#checkstyle.maxmethodlen =

# Specifies the maximum constructor length.
# Default value is defined here. 
#checkstyle.maxconstructorlen =

# Specifies the maximum file length.
# Default value is defined here. 
#checkstyle.maxfilelen =

# Specifies the regular expression to match for to-do comments.
# Default value is defined here. 
checkstyle.pattern.todo = :TODO:

# Specifies the regular expression to match against member variables.
# Default value is defined here. 
checkstyle.pattern.member = ^_[a-z][a-zA-Z0-9]*$

# Specifies the regular expression to match against public member variables.
# Default value is defined here. 
#checkstyle.pattern.publicmember =

# Specifies the regular expression to match against parameters.
# Default value is defined here. 
#checkstyle.pattern.parameter =

# Specifies the regular expression to match against static/final variables.
# Default value is defined here. 
checkstyle.pattern.const = ^[A-Z][_A-Z0-9]*$

# Specifies the regular expression to match against static variables.
# Default value is defined here. 
checkstyle.pattern.static = ^_[a-z][a-zA-Z0-9]*$

# Specifies the regular expression to match against type names.
# Default value is defined here. 
#checkstyle.pattern.type =

# Specifies the regular expression to match against method names.
# Default value is defined here. 
#checkstyle.pattern.method =

# Specifies the regular expression to match against local variable names.
# Default value is defined here. 
#checkstyle.pattern.localvar =

# Specifies the file containing the header lines.
# Default is to not check. 
#checkstyle.header.file =

# Specifies whether to interpret each line in the checkstyle.header.file as
a regular expression.
# Default is "no". 
#checkstyle.header.regexp =

# Specifies a comma separated list of the lines in the header to ignore when
comparing.
# Default is to not ignore any line. 
#checkstyle.header.ignoreline =

# Specifies the visibility scope where javadoc comments are checked.
# Valid values are "nothing", "public",  "protected",
#                  "package", "private", "anoninner".
# Defaults to "private". 
#checkstyle.javadoc.scope =

# Specifies whether to require that package documentation is available.
# Defaults to "no". 
checkstyle.require.packagehtml = yes

# Specifies whether to ignore checking import statements.
# Defaults to "no". 
#checkstyle.ignore.imports =

# Comma separated list of package prefixes that are
# not allowed in import statements.
# Defaults to "sun". 
#checkstyle.illegal.imports =

# Comma separated list of fully qualified class names
# that are not allowed to be instantiated.
# Defaults to "". 
#checkstyle.illegal.instantiations =

# Specifies whether to ignore checking whitespace.
# Defaults to "no". 
#checkstyle.ignore.whitespace =

# Specifies whether to ignore checking for whitespace after a cast.
# Defaults to "no". 
checkstyle.ignore.whitespace.cast = yes

# Specifies whether to ignore checking braces.
# Defaults to "no". 
#checkstyle.ignore.braces =

# Specifies whether to ignore checking the L in long integer literals.
# Defaults to "false". 
#checkstyle.ignore.longell =

# Specifies whether to ignore the public keyword in interface definitions.
# Defaults to "no". 
checkstyle.ignore.public.in.interface =

# Specifies the name of a file that can be used to cache details of files
# that pass checkstyle. This can signicantly increase the speed of
checkstyle
# on successive runs. 
#checkstyle.cache.file =

# Specifies whether to check if unused @throws tags are subclasses
# of java.lang.RuntimeException.
# Defaults to "false". 
checkstyle.javadoc.checkUnusedThrows =

# Specifies a base directory for reporting file names relative to.
# Defaults to "". 
#checkstyle.basedir =


-----Original Message-----
From: Oliver Burn [mailto:checkstyle@puppycrawl.com] 
Sent: Monday, July 08, 2002 6:25 AM
To: ant-user@jakarta.apache.org; turbine-maven-dev@jakarta.apache.org
Subject: Checkstyle 2.3 released

Announcing release of 2.3 of Checkstyle is available at:

           http://checkstyle.sourceforge.net/

What is it?
===========

Checkstyle is a development tool to help programmers write Java code
that adheres to a coding standard. Its purpose is to automate the
process of checking Java code, and to spare humans of this boring (but
important) task.  Checkstyle can be run via an ANT task (recommended)
or a command line utility.

Third-party plug-ins are available for Maven, jEdit, NetBeans,
Centipede, JBuilder, Eclipse/WSAD, Emacs JDE.

New features:
=============

  - Support checking to determine if an unused @throws exception is a
    subclass of java.lang.RuntimeException
  - Detect instantiations of classes that should not be instantiated
    (e.g. java.lang.Boolean)
  - Added ability to specify the base directory for reporting file
    names
  - Check for line wrapping on operators
  - Detect empty try blocks
  - Detect empty catch blocks
  - Detect empty finally blocks
  - Detect to-do comments
  - Detect use of lowercase l ("ell") in long integer literals
  - Include column number in the XML output
  - Added ability to specify a properties file on the command line
  - Check for whitespace around "{" and "}"
  - Fix Javadoc errors under JDK 1.4 (request 568553)
  - Detect redundant abstract modifier in interfaces
  - Support running Checkstyle using the -jar option

Resolved bugs:
==============

  - Better error reporting for missing properties files
  - Ant task now logs style violations as errors

API changes (only relevant for IDE plugin authors):
===================================================

  - The get/setOutputStream methods have been removed from the
    AuditListener interface. The XMLLogger and DefaultLogger
    implementations now expect OutputStreams to be provided as a
    constructor argument.
  - The DefaultLogger now differentiates between info messages
    ("started checking file ...", etc.) and error messages (style
    errors found by checkstyle).

Regards,
Oliver


--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>

--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message