Hi,
What is the best tool if I want to check that a method like
System.out.println() is only called from a certain class?
I would like to enforce certain programming conventions by adding these
checks to the nightly Ant build process.
regards,
Peter
Robert Klemme - 21 May 2005 20:51 GMT
> Hi,
>
[quoted text clipped - 3 lines]
> I would like to enforce certain programming conventions by adding these
> checks to the nightly Ant build process.
What about grep? AFAIR ant can search through files also.
robert
Meetlint - 21 May 2005 21:28 GMT
> What about grep? AFAIR ant can search through files also.
I gave a simple example but in the future I would like to write more
specific rules, which get very close to Java parsing...
I will be looking at http://classycle.sourceforge.net/ which says:
Classycle's Dependency Checker searchs for unwanted class dependencies
described in a dependency definition file. Dependency checking helps to
monitor whether certain architectural constrains (e.g. in a layered
architecture) are fulfilled or not.
thanks,
Peter
Dale King - 26 May 2005 05:25 GMT
> Hi,
>
[quoted text clipped - 3 lines]
> I would like to enforce certain programming conventions by adding these
> checks to the nightly Ant build process.
It could be fairly easily done in Checkstyle. They show an example
GenericIllegalRegexp that checks for System.out.println here:
<http://checkstyle.sourceforge.net/config_misc.html#GenericIllegalRegexp>
The only other thing to do is supress the error for the class where you
allow it.
Another similar tool that could do it is PMD. If you know your way
around XPATH this may be a better choice. They have the rule for finding
the println statements here:
<http://pmd.sourceforge.net/rules/logging-java.html>
You would only have to modify the XPATH instruction to only look when
the it is inside a class whose name does not match your class.
Checkstyle and PMD both have ant tasks BTW.

Signature
Dale King