Sounds great... I've used checkstyle for a while now and it has done a
good job for the most part.  

About the 9,000 errors it produced (maybe errors is not the right word)
- a good many of them are probably due to the difference between the Sun
Coding standards and the Apache coding standards.  I have mostly
followed the Sun standards in my projects and are not as familiar with
the Apache rules.  Do you think that most of these are due to the
discrepencies betwix the two?  I am not advocating fixing them, just
wondering...

Bill



-----Original Message-----
From: Martin Cooper [mailto:[EMAIL PROTECTED]] 
Sent: Sunday, January 05, 2003 2:20 AM
To: [EMAIL PROTECTED]
Subject: New PMD and Checkstyle tasks


I've added two new tasks to the main build.xml file to allow us to
easily run PMD and Checkstyle on the entire src/share source tree. Even
if you don't know what these tools are, read on.

PMD
---

PMD is a Java source code analyzer which can detect many, many different
kinds of problems, including unused imports, unused variables, etc., and
report them in different ways.

To run the PMD task, you need to first download PMD from here:

http://sourceforge.net/projects/pmd/

and set the pmd.jar property in your build.properties file with
something like this:

pmd.jar = /Java/pmd/lib/pmd-1.01.jar

Then you can invoke the task like this:

ant pmd

This will create an HTML output file named pmdreport.html in the Struts
root directory. The task is configured to report only unused imports,
duplicate imports, and unused variables and methods, but we can expand
the set of checks and/or use multiple targets for different sets of
checks as we gain more experience with it.

Checkstyle
----------

Checkstyle is a tool that checks source code against a defined set of
coding conventions. The default is to check against the Sun coding
conventions, and I've left the settings at the default for now.

To run the Checkstyle task, you need to first download Checkstyle from
here:

http://sourceforge.net/projects/checkstyle/

and set the checkstyle.jar property in your build.properties file with
something like this:

checkstyle.jar = /Java/checkstyle-2.4/checkstyle-all-2.4.jar

Then you can invoke the task like this:

ant -logfile checkstyle.log checkstyle

Right now, you *will* need to specify a log file, because Checkstyle is
reporting 9,884 errors! Note that I am *not* advocating that we start a
crusade to fix these before Struts 1.1 Final. In fact, I think that
would be counterproductive at this point.


Each of the tasks described above is conditional on the corresponding
property being set in your build.properties file. If the property is not
set, invoking the task simply does nothing.

At some point, it might be nice to have these tasks generate XML and run
the output through XSLT to generate customised HTML. However, if we move
to Maven (which I'd really like to do as soon as both 1.1 Final and
Maven are released), we may not need to worry about this.

--
Martin Cooper



--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to