In our latest work, we've been investigating (using free software projects) how programs violate best practices. To see this, we compile a program and request that the compiler outputs certain warnings (i.e. a complaint about code that is valid but potentially poor practice). We then collect these warnings and perform some magic (a.k.a. analysis) on them. (This is all part of wider work investigating the quality of software in organized free software "forges" -- hopefully I'll blog about that in future.)
In doing so, we've used a relatively simple measure to profile best practice violations: warning density.
There is a colossal smorgasbord of warnings to choose from. Just printing the information on warning options from the G++ man page takes 22 pages. So, in one approach, we've requested a relatively small set of warnings, namely the warnings from Scott Meyers's Effective C++ book (the so-called

These are the number of "Weffc++" warnings per thousand lines of code in KDE at various snapshots in its past.
I anticipated that warning density would be theoretically and experimentally very similar to defect density, but there are some critical differences:
But is all this "warning density" jazz interesting?
In doing so, we've used a relatively simple measure to profile best practice violations: warning density.
There is a colossal smorgasbord of warnings to choose from. Just printing the information on warning options from the G++ man page takes 22 pages. So, in one approach, we've requested a relatively small set of warnings, namely the warnings from Scott Meyers's Effective C++ book (the so-called
-Weffc++ option). To illustrate it, let's look at results of one experiment:
These are the number of "Weffc++" warnings per thousand lines of code in KDE at various snapshots in its past.
I anticipated that warning density would be theoretically and experimentally very similar to defect density, but there are some critical differences:
- With defect density it is always a concern that you have not discovered most of the defects in the code -- indeed software with close to zero defect density might just mean that the software has not been thoroughly debugged. Conversely, warnings are trivially and automatically discoverable.
- However, warnings (I would say) are weaker indicators of software quality -- after all, which would you rather know about: potential dodgy practices or actual defects that effect how the software runs?
- At the top system level there seems to be a direct correlation, like defect density, between warning density and size, so you might expect very small modules to have very small warning densities. But if you look at smaller subsections, that correlation weakens so much as to practically disappear. For example:
- kdelibs (with about 570,000 LOC) has a warning density of ~2 warnings/kSLOC
- kdetoys (about 10,000 LOC) has a density of ~15 warnings/kSLOC
- kdepim (about 550,000 LOC) has a density of ~9 warnings/kSLOC.
- And, most interestingly to me, I suspect that resultant warnings can be effected strongly by things like established coding practices. It's easy for organized software projects to establish and enforce a policy, for example, that says "all destructors should be virtual in base classes". In doing so, you reduce the possibility of destructor-related defects and reduce the "Weffc++" warning density.
But is all this "warning density" jazz interesting?

Calendar



