Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I am doing my masters dissertation and I have conducted a software metrics. I need to adopt my metrics on an open source tool. I have found PMD and check style on sourceforge.net but there is not adequate explanation about their codes. However, I couldn't to find their source code to customize them.

I will be appreciated, if you introduce one open source tool for java which I can customize it's code.

share|improve this question
    
1  
Can you give us more details on what you are trying to do? At the moment your question is closed as not constructive because it is vague, and it's hard to point you in the right direction, apart from giving you links to the source code repositories of various tools (which popular search engines can already give you in a heartbeat and a few keystrokes). What are you trying to achieve for your dissertation, and with these tools in particular? Do you need bytecode analysis or source code analysis? We need more context, give us as much as you can. –  haylem Nov 20 '12 at 14:57
    
Sorry, I realize you mentioned "source code analyzer" in your question's title. I had mentally blocked that (maybe because I've seen people get confused before). –  haylem Nov 20 '12 at 15:00
    
PMD compiles the java code to XML and then runs xpath queries against that XML. It is possible to extend PMD with custom rule sets of new xpath queries. For example //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 '13 at 18:38
add comment

closed as not a real question by Walter, gnat, MainMa, GlenH7, Thomas Owens Nov 20 '12 at 14:51

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

3 Answers

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.

share|improve this answer
    
Thank's, it is very useful. –  daneshkohan Nov 21 '12 at 8:34
add comment

Sonar is a major open source code analysis tool from CodeHaus

You can find it here: http://www.sonarsource.org/

It normally works in conjunction with Jenkins as part of a continuous integration environment. After Jenkins completes the build Sonar picks it up and performs a wide range of analyses on it.

share|improve this answer
add comment

Wikipedia has a list of code analysis tools, including a section on Java tools.

FindBugs is an open source project and appears to be active as of July 2012.

This article at the Java Lobby has a list of open source tools, including JDepend and JavaNCSS. They recommend checking out Pantiopticode.

Another tool that you should check out is the Eclipse Metrics Plug In.

share|improve this answer
    
I already saw this page, but my problem is their code are not available to customize. –  daneshkohan Nov 20 '12 at 2:19
    
Pantiopticode seems rather dead and to have stalled at the 0.1 release (which is not uncommon from a college project). Doesn't mean it's not worth checking out though. –  haylem Nov 20 '12 at 14:40
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.