Is there a quick way, in Visual Studio, to know how many lines of code exist in a project?
+1
A:
I've used SourceMonitor. Works well enough.
See also the answers on: Simple script to count NLOC?
Shog9
2009-02-23 19:41:08
+3
A:
In Visual Studio 2008, right click a project and select "Calculate Code Metrics". It includes a few other metrics like cyclomatic complexity. However, it only counts real lines of code, not empty lines or lines with }'s for example.
Paul Stovell
2009-02-23 19:42:31
What version(s) of VS2008 is this in? I'm running Professional, and don't see it...
Shog9
2009-02-23 19:50:22
Might be a team edition thing
Paul Stovell
2009-02-23 20:07:01
It is team edition only - on the developer menu. Not that we have it, because like most people we don't use team.
Bob Moore
2009-02-23 20:17:49
A:
Install cygwin, start a bash shell, cd to the top directory and issue something like:
find . -name "*.cpp" -exec cat {} \; | wc -l
Paul.
Paul W Homer
2009-02-23 19:45:42
This ignores .c/.h files, forks a new process for every source file, doesn't give a final total, and counts meaningless lines (blank lines, comments, lines containing only braces, etc.)
Adam Rosenfield
2009-02-23 20:15:09
I generally get the counts for the header files independently; don't care about CPU usage and believe that there are no such things as meaningless lines.
Paul W Homer
2009-02-23 21:05:12
You can also do 'find . -name "*cpp" | xargs cat | wc -l', or in zsh (and possibly bash 4) 'wc -l **/*cpp | tail -n1'.How do you do it in windows without visual studio?
Jonas Kölker
2009-03-19 21:57:04
Install a Unix shell like Cygwin. Or if you have a real sense of fun, install a VM emulator like VirtualBox, and a Linux distro like Debian, share the Windows filesystem into Samba and then hit the sources directly with bash.
Paul W Homer
2009-03-21 15:42:13
+1
A:
For a more general solution which will give you line counts and many more useful metrics, I can strongly recommend Source Monitor which is free and can be integrated with VS.
anon
2009-02-23 20:10:48