[Insight-developers] Anyone looked at cppcheck for static analysis of ITK?
kent williams
norman-k-williams at uiowa.edu
Thu Sep 3 11:59:51 EDT 2009
I wouldn't mind taking some time to work on cppcheck-correcting ITK, but of
course, it would be better if the people who 'own' particular files look at
cppcheck's suggestions and modify the code based on their intimate knowlege
of it. I doubt that there will be much in the way of real bugs found, but it
will help in reability and maintainability.
There are complaints cppcheck generates that maybe ought not be fixed. For
instance, cppcheck thinks every member variable in a class should be
initialized in the constructor. This might hurt performance in some cases,
if they're in classes that get created and destroyed in 'inner loop'
situations.
On the other hand, it's hard to think of a case where leaving member
variables unitialized is a good idea: if they're used as temporaries in
class methods, they should be moved inside the methods. If there's a
possible sequence of method invocations that could use them uninitialized,
that's a defect. If initialization is separate from instantiation, they
should be set to values that will act as guards if initialization is
skipped.
On 9/3/09 3:41 AM, "Mathieu Malaterre" <mathieu.malaterre at gmail.com> wrote:
> On Wed, Sep 2, 2009 at 8:16 PM, kent
> williams<norman-k-williams at uiowa.edu> wrote:
>> I was running cppcheck over all our application source code, and while it
>> didn't find any actual errors, it does pick up some style issues worth
>> addressing in our code.
>
> I did so, but for another well know open source project ;)
>
> <...>
>> Is this anything we want to think about using on a regular basis?
>
> Definitely. There is some work to be done on the CDash side of things,
> but AFAIK there are some interest.
>
> 2cts
More information about the Insight-developers
mailing list