I have 2 projects registered on Ohloh. Since I strive for well-documented code, I was happy to see that my older Java project (unfortunately on the back burner, for now) fares pretty well in that regard (44% vs. 33% average). However, when I added my more recent Objective-C project, I was quite surprised to see it rated as "Few source code comments", with a density of only 8%.
This seemed completely out of line with the amount of comments I write — my header files alone are 75% comments on average, since the project is a library with lots of public APIs. For samples, see any of the header files at this WebSVN link.
Then I realized that the page that explains the comment density metric says that the figure is measured as lines that are comments. To avoid the frequent reformatting I used to have to do just to stay within 75/80 columns, I converted my comments to be soft-wrapped wherever possible, rather than having hard line breaks. This improves the presentation of the comments, but leads to long lines of comments that only count as one each, even if they occupy more than one line at normal document width. (Mine often span 5 or more.) Hmmmm.
This makes me wonder whether very sparse comments covering many lines would similarly count as "good commenting". Of course, simple automated parsing can't decipher anything about the quality of the comments, but I think it's apparent that just measuring line count may not be so helpful for getting a sense of the true nature of in-code comments.
It would seem to be more accurate to measure something like percent of characters in a file that are comments. Given the common use varying code styles (such as always/never putting curly braces on new lines) it would also seem more prudent to discount extraneous whitespace and calculate based on true proportions, not just a line-based heuristic.
Thoughts?