Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Checkstyle and Findbugs for changed files only on Jenkins (and/or Hudson)

We work with a lot of legacy code and we think about introducing some metrics for new code. Is it possible to let Findbugs and Checkstyle run on changed files only instead of a complete project?

It would be nice to assure that only file with a minimum of quality is checked in, but the code base itself is not (yet) touched and evaluated not to confuse people by thousands of issues.

like image 246
Rick-Rainer Ludwig Avatar asked Aug 30 '11 12:08

Rick-Rainer Ludwig


2 Answers

In theory, it would be possible. You would use a shell script to parse the SVN (or whatever SCM) change logs after a given start date, identify the .java files from these change sets and build two patterns from these:

  • The Findbugs Maven Plugin expects a comma-separated list of class (or package) names for the parameter onlyAnalyze, so you'll have to translate file names to fully qualified class names (this will get tricky when you're dealing with inner classes)
  • The Maven Checkstyle Plugin is even worse, it expects a configuration file for its packageNamesLocation parameter. Unfortunately, only packages are allowed, not individual files. So you'll have to translate file names to packages.

In the above examples I assume that you are using maven. I am pretty sure that similar things can be done with ant, but I wouldn't know.

I myself would probably use a Groovy script instead of a shell script to achieve the above results.

like image 82
Sean Patrick Floyd Avatar answered Sep 29 '22 10:09

Sean Patrick Floyd


Findbugs has ant tasks that can do diffs against different findbugs results to see just the deltas, so only reporting new bugs, see

http://findbugs.sourceforge.net/manual/datamining.html

like image 28
MeBigFatGuy Avatar answered Sep 29 '22 09:09

MeBigFatGuy