1

Is there a tool that calculates various LOC statistics? It would have to support popular languages like C++, C#, Python, PHP, JavaScript, ActionScript, etc and interpret code accordingly.

An example of the statistics I'm looking for:

  • 350 Physical lines of code -- including braces
  • 200 Logical lines of code -- actual code
  • 190 Comment lines
  • 68 Variables
  • 28 Methods/Functions
  • 5 Classes
  • 3 Namespaces
Robin Rodricks
  • 110,798
  • 141
  • 398
  • 607
  • 3
    Do remember that more lines of code does not make better code, and loads of documentation lines, does not make good code or documentation. It is the contents of those lines that matter, making counting LOC statistics useless for anything else besides vanity. – alexanderpas Sep 11 '10 at 04:48
  • @alex: agreed. Where I work, everyone views SLOC with the opposite intent... to minimize it. People with high LOC count are considered inferior developers! :) Unfortunately, some contracts use source lines of code as the only metric of productivity. – gMale Sep 11 '10 at 06:57
  • 1
    using LOC to measure Productivity is like using the weight of a man to measure his maturity. – Rune FS Sep 11 '10 at 09:41
  • Measuring Cyclomatic Complexity or Halstead measures gets you a value which isn't dependent on just physical line count. – Ira Baxter Sep 13 '10 at 01:47

3 Answers3

2

You want to measure a wide range of langauges. In general it is hard to get a single tool to do that, because it has to know too much about all the langauges of interest.

Our Source Code Search Engine is a commercial tool for searching an organization's code base across multiple languages. It uses separate language-specific front ends to "parse" each of the langauges it supports so it can build an index to support fast search for that language taking advantage of the precise lexical syntax of each langauge. The search engine front ends cover all the langauges in your list off-the-shelf except ActionScript (and that might not be very far off).

A side effect of of the indexing step is the computation of SLOC, comment-count, whitespace-line-count, as well as cyclomatic and halstead measures for each file, produced as XML document. So you can scan a code base of 10,000 files and get relative metrics for each file. It does not count methods/functions, etc.

Ira Baxter
  • 93,541
  • 22
  • 172
  • 341
  • +1: Good answer, Ira, though you might have been more specific in stating that this is a tool created by your company. Not everyone will look at your profile to determine this. – John Saunders Sep 13 '10 at 02:03
  • 1
    I have followed SO policy, and noted specifically that it is *our* product. See the text in the answer; no need to look at my profile. – Ira Baxter Sep 13 '10 at 02:11
1

Here's a great list:

http://www.locmetrics.com/alternatives.html

gMale
  • 17,147
  • 17
  • 91
  • 116
0

I found these apps capable of LOC statistics for Flash/Flex ActionScript projects.

Robin Rodricks
  • 110,798
  • 141
  • 398
  • 607