Click here to Skip to main content
15,879,348 members
Please Sign up or sign in to vote.
4.50/5 (2 votes)
See more:
Can anyone recommend a Windows-based software metric tool that is able to:

Calculate lines of code in a particular software project. I would like to point it to a folder and the tool should recurse through all subfolders and search through all source files (e.g. *.cpp, *.c, *h, as specified), then provide the following metrics:

Number of *.cpp, *.c, *.h modules, with a line per module with some stats as below
Number of lines of code
Number of lines of comments and ratio of comments to source code
And some totals for the project

There is no need to do lint-type checking.

Obviously my example refers to C/C++ file types but it would also apply to other languages.

I don't necessarily think this should integrate with any IDE (and work off project files) - rather work on the idea that all files under certain folder should be included. This is because we are using several different tool chains.

This is of course something easy enough to write but I am sure there is something available somewhere.
Posted
Updated 4-Apr-11 15:24pm
v2

I used Microsoft Line of Code Counter[^], it's a decent tool. I used it with C#, but I think it works with other languages as well.
 
Share this answer
 
Comments
Albert Holguin 4-Apr-11 22:49pm    
what does it do with text files that are not source? do they get added as if they were source or does it distinguish? ...asking mostly out of curiosity...
dasblinkenlight 5-Apr-11 6:09am    
I think they provide options for you to control file/directory inclusion or exclusion. In general, I remember the setup being somewhat non-trivial (you set up a counting job first, with lots of config options, and then you run a job to obtain the actual counts). The counts are grouped by category (C#, XML, etc.), by project directory, and so on.
Albert Holguin 5-Apr-11 9:56am    
reason that came to mind is that in my case, svn has somewhat "polluted" my source with the files it uses to track changes, those I wouldn't want to count in a case such as this (I used "polluted" in quotes because I don't seem to mind but others do, hence mercurial taking a different approach)
dasblinkenlight 5-Apr-11 10:08am    
I use svn too - convincing MSLCC to ignore what's in .svn directories was not hard (it may have even happened "automagically", I don't remember the details).
Albert Holguin 5-Apr-11 10:11am    
well that's good... my 5 for the details!
Michael,

I use SourceMonitor http://www.campwoodsw.com/sourcemonitor.html[^]
.
 
Share this answer
 
Well how about Oz Solomon's "Project Line Counter"? We tried this on few projects a while ago in VC6. It worked pretty good.

Project Line Counter Add-In v2.10 for VS.NET and VC6[^]
 
Share this answer
 
This metrics tool does not look very useful.
If you want to measure programmer's performance using number of files and lines, you would highly demotivate them.

Anyway, you will find all you need if you use the following Microsoft assemblies bundled with .NET Framework: Microsoft.Build.Framework; see also Microsoft.Build.Engine, Microsoft.Build.Utilities. For custom tasks, use Microsoft.Build.Tasks. In a nutshell, you can add a custom task which analyzes existing projects and output the statistics you need. You can add such task in a special project of your solution or an existing project.

See MSBuild help: http://msdn.microsoft.com/en-us/library/dd293626.aspx[^].

—SA
 
Share this answer
 
Comments
Michael Melkonian 4-Apr-11 21:50pm    
Thanks for that. As I said I am looking for something generic and NOT integrated with MS .Net.

Line of code metrics can be very useful in some circumstances. No one is suggesting this as a motivational tool. Anyhow, I did not intend this question as a discussion on s/w project management.
Sergey Alexandrovich Kryukov 5-Apr-11 13:11pm    
You did not understand. What I suggest is NOT integrated with .NET. (Not in all cases.) MSBuild is a separate application using its declarative language. That's it. If you not using custom tasks, you're just writing XML project.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900