Question

I know there are quite a few line count tools around. Is there something simple that's not a part some other big package that you use ?

Was it helpful?

Solution

Slick Edit Gadgets has a nice report breaking it down by lines of code, whitespace and comments. The plug-in is free and relatively small.

OTHER TIPS

Sorry if it's not a direct answer but these days I much prefer to use code metric tools or profilers rather than lines of code. Ants profiler and NDepend are two that immediately come to mind.

It's just that these tools allow you to get a real grasp on the size/complexity of your software, lines of code is a very primitive metric.

I use this Python script:

import os, sys
total_count = 0
for root, dirs, filenames in os.walk(sys.argv[1]):
  dirs[:] = [ # prune search path
    dir for dir in dirs
    if dir.lower() not in ('.svn', 'excludefrombuild')]
  for filename in filenames:
    if os.path.splitext(filename)[1].lower() in ('.cpp', '.h'):
      fullname = os.path.join(root, filename)
      count = 0
      for line in open(fullname): count += 1
      total_count += count
      print count, fullname
print total_count

If you have Visual Studio 2008 Team Developer or Team Suite edition, you can get them directly in Visual Studio using Code Metrics.

You could use find and wc from this relatively small package, http://unxutils.sourceforge.net/

Like

find . -name *.cs -exec wc -l {} \;

Or, if you have a linux machine handy you can mount the drive and do it like that, and it'll give you a ballpark figure. You can complexify to remove comments, etc. But given that you just want a ballpark figure, shouldn't be necessary.

Right click on Project in Solution explorer and select "Calculate Code Metrics".

not sure if this works in VS08 ... code project

Exact Magic's StodioTools package (free) shows Executable LoC among other metrics. This is a plug-in to VisualStudio 2008.

Project Line Counter is pretty cool, but you need an updated .reg file for VS 2008 and later. I have a .reg file for Visual Studio 2010 on my website: http://www.onemanmmo.com/index.php?cmd=newsitem&comment=news.1.41.0 There's some instructions in the discussion at CodeProject http://www.codeproject.com/KB/macros/linecount.aspx with info on getting it to run with Visual Studio 2008.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top