You can approach your tool from various angle, so not being entirely sure if you're set on one I'll enumerate your options. You could either:
- write a Sonar plugin which packages:
- your own analyzer,
- or a modification of another analyzer,
- or write a standalone analyzer or extend an existing one.
Batteries Included: Go with Sonar
As recommended by others, Sonar (source) would at the moment be considered the most prevalent and versatile code analysis tool, but it's a bit more than that: it's a continuous inspection server, integrating with a great many other tools, on top of providing its own analyzers.
Independent Analyzers
If you're looking for an existing analyzer to modify or integrate with Sonar, you may want to look at either:
Some of these are a more or less dated and actively maintained, and also more or less easy to get your hands dirty with. So you may want to survey them and experiment a bit. I'd recommend a look at JDepend, as it's a relatively small code base and it once was (and still is by some) a rather famous and well received tool.
IDE Support
Most of these tools can be integrated into an IDE (whether or not that's something you have in mind, I don't know) like Eclipse. PMD, CheckStyle and FindBugs for instance all come with an Eclipse plugin, and so does Sonar as well.
Source Code vs Bytecode Analyzers
Finally, be aware that some tools perform an analysis on source code (e.g. CheckStyle) while others do it on bytecode (e.g. FindBugs). You may want to look at either one or both of these options.
Commercial / Closed-Source
Also, if your question was just about adding new metrics and not necessarily extending the software programmatically, you could also look at some other tools. For instance, Google's CodePro Analytix is also pretty good and free and comes with IDE plugins, for instance, while not open-sourced.
//VariableDeclarator [parent::FieldDeclaration] [../Type/ReferenceType /ClassOrInterfaceType[@Image='SimpleDateFormat'] and ..[@Static = 'true'] ]will detect statically declared SimpleDateFormat objects. For such, it isn't necessary to modify PMD's code in most cases when it can be extended. See pmd.sourceforge.net/pmd-5.0.1/howtowritearule.html – MichaelT Jan 14 at 18:38