A few years ago I wrote a small utility to count the number of comments. It was very interesting to count and analyze comments in projects over which he worked, and subsequently in large Open Source projects. This article presents the results obtained for popular Open Source projects.
The results table is provided below and consists of the following columns:
')
1. Project name and version.
2. The number of characters code.
3.% of comments from the total amount of code.
4. The ratio of the number of lines of code to the number of comments.
5. The number of words todo + fixme. Indicator of how much is left to finalize the project.
Name and version | Amount of code | % of comments | lines of code / comments | todo + fixme |
---|
Apache OpenOffice 3.4.1 | 279 M | 16.3% | 3.3 | 6557 |
Mozilla Firefox 14.0.1 | 163 M | 25.5% | 4.5 | 1338 |
Qt 4.6.4 | 57 M | 19.9% | 7.0 | 395 |
Blender 2.63 | 71 M | 10.9% | 6.0 | 1477 |
Gimp 2.8.2 | 33 M | 7.7% | 10.6 | 227 |
OGRE 1.9.0 | 23 M | 23.5% | 3.5 | 421 |
Inkscape 0.48.2 | 19 M | 18.7% | 5.0 | 1556 |
VLC media player 2.1.0 | 20 M | 14.7% | 6.3 | 1155 |
Php 5.4.6 | 45 M | 10.6% | 6.2 | 277 |
Mediawiki 1.19.1 | 15 M | 14.8% | 5.0 | 546 |
7-zip 920 | 4.2 M | 5.9% | 25.6 | 0 |
Zlib 1.2.7 | 694 K | 40.9% | 4.0 | 0 |
Analysis Note:
Zlib analyzed all files except the contrib directory.
Qt analyzed the qt-everywhere-opensource-src-4.6.4 \ src folder with the exception of the 3rdparty.
In wikimedia, all folders except languages ​​were analyzed (thanks for the advice).
Samples folder has been excluded from Ogre.
It is worth noting that the first comment of the file was not taken into account when calculating, because most likely it is a copyright. From the above results it can be seen that on average the number of comments is about 15%. Of course, OpenOffice stands out with 6557 fixme + todo. From these comments:
- 50 comments look like this: "TODO: check overflow!".
- About 10: "TODO TODO TODO: this O (n) search really sucks ...".
- 68 comments like “get rid of”.
- 94 comments “TODO document me”
If you want to conduct this test yourself, link to the utility:
unick-soft.ru/soft/commentCounter.zipThanks to
VBart for the link to the
www.ohloh.net service where you can find a large number of open source projects. Among other things, the service displays statistics on the number of comments in them.