Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Number of lines in code [closed]

Tags:

c#

Is there a tool or something else to count the number of lines in a specific C# project? Just out of curiosity...

like image 956
George Silva Avatar asked Jan 15 '10 00:01

George Silva


People also ask

How do you calculate the number of lines of code?

Take one of your existing project, get the number of lines and divide it by the time it took you to code it. This will give you a kind of lines per hour metric. Then, try to estimate how many time you have worked with that specific language and multiply it with your already calculated metric.

How many lines of code is too many for one?

Large files tend to do a lot of things and can make it hard following what's going. While there is not an objective maximum number of lines considered acceptable in a file, most people would agree it should not be in the thousands. Recommendations usually range from 100 to 500 lines.

What is considered a line of code?

Lines of code are the "source code" of the program, and one line may generate one machine instruction or several depending on the programming language. A line of code in assembly language is typically turned into one machine instruction.

How can I see the total lines of code in Visual Studio?

In VS2010 there is a in-built tool that counts all lines of code and other values too: Go to View -> Other Windows -> Code metrics results.


Video Answer


2 Answers

I believe there are tools, but I find it easier to just use the Find in Files option and use this regex:

^~(:Wh@//.+)~(:Wh@\{:Wh@)~(:Wh@\}:Wh@)~(:Wh@/#).+

That regex is from here, which also shows how to search for it. It will return a number of matching lines (i.e. the number of lines in your code)

like image 128
keyboardP Avatar answered Oct 02 '22 00:10

keyboardP


In Visual Studio 2010 Premium and Ultimate, you can go to the Analyze tab and select "Calculate Code Metrics", it gives you lines of code as well as a maintainability index, cyclomatic complexity, depth of inheritance and class coupling metrics, project by project.

You can drill into namespaces and classes/interfaces as well.

like image 28
Guy Starbuck Avatar answered Oct 02 '22 01:10

Guy Starbuck