Hi,
Is it possible to find the number of lines of code in an entire solution? I've heard of MZ-Tools but is there an open source equivalent?
Hi,
Is it possible to find the number of lines of code in an entire solution? I've heard of MZ-Tools but is there an open source equivalent?
You could use:
An open source line counter for VS2005, 2003 and 2002 is available here:
There is also discussion of creating a line counting VS addin, complete with code on Codeproject, here
http://www.codeproject.com/KB/macros/LineCounterAddin.aspx
Also Slick Edit Gadgets have a nice line-counter, here:
http://www.slickedit.com/content/view/441
and Microsoft Visual Studio Team System 2008 includes a good line counter.
Just remember though:
Measuring programming progress by lines of code is like measuring aircraft building progress by weight. Bill Gates
In Visual Studio Team System 2008 you can do from the menu Analyze--> 'Calculate Code Metrics for Solution' and it will give you a line count of your entire solution (among other things g)
I've found powershell useful for this. Because I consider LoC to be a pretty bogus metric anyway, I don't believe anything more formal should be required.
From a smallish solution's directory:
PS C:\Path> (dir -include *.cs,*.xaml -recurse | select-string .).Count
8396
PS C:\Path>
That will count the non-blank lines in all the solution's .cs and .xaml files. For a larger project, I just used a different extension list:
PS C:\Other> (dir -include *.cs,*.cpp,*.h,*.idl,*.asmx -recurse | select-string .).Count
909402
PS C:\Other>
Why use an entire app when a single command-line will do it? :)
cloc is an excellent commandline, Perl-based, Windows-executable which will break down the blank lines, commented lines, and source lines of code, grouped by file-formats.
Now it won't specifically run on a VS solution file, but it can recurse through directories, and you can set up filename filters as you see fit.
Here's the sample output from their web page:
prompt> cloc perl-5.10.0.tar.gz 4076 text files. 3883 unique files. 1521 files ignored. http://cloc.sourceforge.net v 1.07 T=10.0 s (251.0 files/s, 84566.5 lines/s) ------------------------------------------------------------------------------- Language files blank comment code scale 3rd gen. equiv ------------------------------------------------------------------------------- Perl 2052 110356 112521 309778 x 4.00 = 1239112.00 C 135 18718 22862 140483 x 0.77 = 108171.91 C/C++ Header 147 7650 12093 44042 x 1.00 = 44042.00 Bourne Shell 116 3402 5789 36882 x 3.81 = 140520.42 Lisp 1 684 2242 7515 x 1.25 = 9393.75 make 7 498 473 2044 x 2.50 = 5110.00 C++ 10 312 277 2000 x 1.51 = 3020.00 XML 26 231 0 1972 x 1.90 = 3746.80 yacc 2 128 97 1549 x 1.51 = 2338.99 YAML 2 2 0 489 x 0.90 = 440.10 DOS Batch 11 85 50 322 x 0.63 = 202.86 HTML 1 19 2 98 x 1.90 = 186.20 ------------------------------------------------------------------------------- SUM: 2510 142085 156406 547174 x 2.84 = 1556285.03 -------------------------------------------------------------------------------
The third generation equivalent scale is a rough estimate of how much code it would take in a third generation language. Not terribly useful, but interesting anyway.
Other simple tool For VS2008 (open source): http://www.accendo.sk/Download/SourceStat.zip
Found this tip: LOC with VS Find and replace
Not a plugin though if thats what you are looking for.
A simple solution is to search in all files. Type in "*" while using wildcards. Which would match all lines. At the end of the find results window you should see a line of the sort:
Matching lines: 563 Matching files: 17 Total files searched: 17
Of course this is not very good for large projects, since all lines are mached and loaded into memory to be dispayed at the find results window.
Try neptuner. It also gives you stuff like spaces, tabs, Lines of comments in addition to LoC. http://neptuner.googlecode.com/files/neptuner_0_30_windows.zip