Re: FileSetCheck

"Lars Kühne" <[email protected]>
Newsgroups gmane.comp.java.audit.checkstyle.user
Message-ID <[email protected]>
I was the main author of that document, so here are my 2 cent (a bit
late, sorry - I was on vacation)

Unused methods:

Like Oliver said, byte code analysis is the way to go here. However,
the ASM approach could be used as the implementation of the
filesetcheck interface. That way (as opposed to the standalone tool
Oliver suggested), you'd get an integrated report for all the problems
in your code, and you can leverage the existing tool chain, like IDE
plugins, Maven reports, etc.

Note however that the document was written years ago, and the world
has changed a bit since then. In most projects I work on, "unused"
public methods would be the norm because of Web templating languages,
reflection, Spring XML config files, etc. All of these mean that
public methods are not referenced in Java source-/bytecode directly.

C# Support:

To make this a bit clearer, actually it *is* a case of writing a new
filesetcheck, only that this implementation would be similar in
size/complexity as the current Checkstyle code base. Like Oliver said,
this is absolutely non-trivial, you would have to rebuild the parser
and code analysis stuff we have for Java. Like the text says, it's a
crazy idea, and you should only try it if you're really bored :-)

Cheers,
Lars

On 6/26/07, Oliver Burn wrote:
> While it is true that there are virtually no limits to what you can do,
> there can often be simpler ways.
>
> To find unused public methods -- as it turns out I wrote a tool to do this
> last week at my work. I did not use Checkstyle at all as it is much easier
> to analyse the byte code using a library like ASM. This is also how FindBugs
> works, and I would recommend this approach when you need rich type
> information.
>
> To find duplicate code -- we have a check already and there is a third party
> as well. See
> http://checkstyle.sourceforge.net/config_duplicates.html
>
> To parse C# -- this would require re-working the code of Checkstyle to
> support this. It is not simply a case of writing new fileset checks. This is
> not a trivial effort.
>
> --Oliver
>
>
>  On 6/25/07, Francisco Costa wrote:
> >
> > Hi!
> > You mention in the website that:
> >
> >
> > There are virtually no limits what you can do in FileSetChecks. The
> craziest ideas we've had so far are:
> >
> > to find global code problems like unused public methods.
> > to find duplicate code.
> > to port the TreeWalker solution to check C# instead of Java.Where can I
> find the code to find the first check, related to unused public methods?
> >
> > Thanks,
> > Francisco

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.