Sunday, July 12, 2009

On the fly analysis of code!

Long long ago, I wrote my first java program in notepad. I wrote my helloworld program, saved and compiled it using 'javac'.

A few compiler errors!!!

I corrected those errors and executed the program. I was happy!

A few years later....

I met eclipse. I wrote my hello world java program using the jdt editor. As soon as I made an error, the java editor showed the errors in red jagged lines. I was excited. I no longer required to finish the entire program to see the compiler errors.

Years passed again! I started to write bigger programs. I started to use a few static analysis tools to make sure my code is of good quality. I use both PMD and Findbugs. But I feel as if I have gone a few years before. I feel as if I am using the notepad again.

To see the code analysis results, I need to complete the coding, then execute the static analysis tools. PMD and Findbugs together might show more than 100 errors.

It was good if the code analysis tools were integrated with JDT. If I type a piece of code, the code should be analysed by the tools on the fly and bring the results. The static analysis tool should not make the end user to wait till he/she manually triggers the analysis.

I could've raised an Eclipse bug in bugzilla if we had a static analysis tool in Eclipse group of projects. How about putting up the analysis logic in the JDT editor? But the code analysis job will be the specialization of static code analysis tools, not JDT. How about JDT exposes some interfaces which the static analysis tools can make use of?

Any thoughts / comments / action over this issue are welcome.



  1. > To see the code analysis results,
    > I need to complete the coding,
    > then execute the static analysis tools.

    FindBugs can do incremental analysis on save. Just enable Project->Properties->FindBugs->Run Automatically.

  2. Thanks Andrei for pointing that out. Infact, even PMD has a similar feature, which runs the analysis on click of 'save'.

    This blog seems to be invalid now. Anyway, this blog helped me to learn about these features.

  3. Hi, if your working on any C/C++ projects you might like to try our tool "Goanna", that's integrated with CDT.