Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do you find source code analyzers useful?

  • Do you use source code analyzers? If so, which ones and for which language development?
  • Do you find them helpful in solving potential bugs in your code? Or are most of their warnings trivial?
  • After prolonged use, do you find your code quality to be higher than before?
like image 269
Yuval Adam Avatar asked Jan 07 '09 08:01

Yuval Adam


People also ask

Why is source code analysis important?

The continuous changes in the source codes and coding methods invite vulnerabilities and risks of defects. This is why code analysis becomes important for any software development cycle to avoid possible failures in the product.

What is source code analyzer?

Source code analysis is the automated testing of source code for the purpose of debugging a computer program or application before it is distributed or sold. Source code consists of statements created with a text editor or visual programming tool and then saved in a file.

What is the benefit of static code analysis?

Static code analysis advantages:It allows a quicker turn around for fixes. It is relatively fast if automated tools are used. Automated tools can scan the entire code base. Automated tools can provide mitigation recommendations, reducing the research time.

How does source code analysis work?

Source code analysis is the automated testing of a program's source code with the purpose of finding faults and fixing them before the application is sold or distributed. Source code analysis is synonymous to static code analysis, where the source code is analyzed simply as code and the program is not running.


1 Answers

I use a few static analysis tools in Java. FindBugs is the first line of defense, catching a lot of common errors and giving pretty useful feedback. It often spots the silly mistakes of tired programmers and doesn't place a high burden on the user.

PMD is good for a lot of other more niggly bugs, but requires a lot more configuration. You'll find that PMDs defaults are often over the top. There are too many rules that are probably beneficial on a tiny scale but ultimately don't help other programmers maintain your code. Some of the PMD rules often smack of premature optimisation.

Probably more useful is the CPD support in PMD. It attempts to find code that has been duplicated elsewhere, in order to make refactoring much easier. Run over an entire project, this really helps determine where the biggest priorities are for cleaning up code and stopping any DRY violations.

Checkstyle is also handy, making sure your coders conform to some coding style standard. it has a bit of overlap with PMD but is generally much more usable.

Finally, Cobertura is a great test coverage suite. Very handy for finding out where the unit tests are lacking, and where you should be prioritising the creation of new tests.

Oh, and I've also been testing out Jester. It seems to be pretty good for finding holes in tests, even where the code has some coverage. Not recommended yet, simply because I've not used it enough, but one to test out.

I run these tools both from within Eclipse and as part of an automated build suite.

like image 194
GaryF Avatar answered Oct 05 '22 07:10

GaryF