5

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.

Rick-Rainer Ludwig
  • 2,371
  • 1
  • 26
  • 42

2 Answers2

3

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.

Sean Patrick Floyd
  • 292,901
  • 67
  • 465
  • 588
  • I am going to use Jenkins, Maven and GIT. Scripting too much was not really preferred. Is there a plugin, option or something already available? We can not be here the first people wanting to check just the new files. – Rick-Rainer Ludwig Aug 30 '11 at 13:20
  • @Rick-Rainer when you have unusual requirements, you usually have to implement them yourself. Sorry. – Sean Patrick Floyd Aug 30 '11 at 14:20
  • I though it would be that unusual... :-( Thanks for the hint, anyways. Maybe someone has a solution out of the box!? – Rick-Rainer Ludwig Aug 30 '11 at 14:37
2

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

MeBigFatGuy
  • 28,272
  • 7
  • 61
  • 66
  • Actually, that's a nice feature. One can check for new introduced bugs that way. This helps a little. I think, one can also introduce this feature into Maven somehow. I'll check this. Thanks for the hint! – Rick-Rainer Ludwig Sep 12 '11 at 08:53