Posts Tagged ‘static code analyzer’

Codan The Barbarian

October 16, 2011 Leave a comment

In the Indigo release of Eclipse‘s C++ Development Tools (CDT) plugin, the Codan static code analyzer runs in real time as you type in your code. As shown below, you can customize the rule set that Codan enforces via the “Preferences/C++/Code Analysis” dialog window.  (My fave is the “ambiguous problem” entry.)

The figure below shows a few examples of Codan in action. While typing in code, a gold (warning) or red (error) bug icon appears adjacent to the line number of the crappy code you write.

Some of Codan’s warnings and errors are also detected by good compilers, but it’s kind of neat that you can discover and correct your defects before running the compiler/linker. This feature is a boon for large programs that take a while to compile and link.

As a long time developer, I’m thrilled to death to have open source tools like Eclipse available to dolts like BD00. I remember the old days when there were not many commercial tools available, yet alone high caliber, open source tool suites like Eclipse.

Cppcheck Test Run

June 22, 2010 2 comments

Since I think that a static code analyzer can help me and my company produce higher quality code, I decided to download and test Cppcheck:

Cppcheck is an analysis tool for C/C++ code. Unlike C/C++ compilers and many other analysis tools, we don’t detect syntax errors. Cppcheck only detects the types of bugs that the compilers normally fail to detect. The goal is no false positives.

After the install, I ran Cppcheck on the root directory of a code base that contains over 200K lines of C++ code. As the figure below shows, 1077 style and error violations were flagged. The figure also shows a sample of the specific types of style and error violations that Cppcheck flagged within this particular code base.

After this test run, I ran Cppcheck on the five figure code base of the current project that I’m working on. Lo and behold, it didn’t flag any suspicious activity in my pristine code. Hah, hah, the last sentence was a joke! Cppcheck did flag some style warnings in my code, but (thankfully) it didn’t spew out any dreaded error warnings. And of course, I mopped up my turds.

Because of the painless install, its simplicity of use, and its speed of execution, I’ve added Cppcheck to my nerd toolbelt. I’m gonna run Cppcheck on every substantial piece of C++ code that I write in the future.

I want to sincerely thank all the programmers who contributed their free time to the Cppcheck project for the nice product they created and unselfishly donated to the world. You guys rock.

%d bloggers like this: