开发者

How to calculate line count for project [closed]

开发者 https://www.devze.com 2023-01-01 10:18 出处:网络
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.

Closed 5 years ago.

开发者_如何学C Improve this question

I am taking a software engineering class right now. Our assignment is to evaluate Mozilla's Thunderbird. Our assignment is to evaluate the size of Thunderbird. One metric that we need to use is the number of lines of code in the project. (Lines of code meaning not including comments or new lines).

Is there a standard way to find the number of lines or am I better off just cracking out a script to do this?

I think that I could do something like this:

# remove all comments
find -name *.java | \
sed "/\/*/,\*\// s/.*//g | \ # remove multiline comments
sed s/\/\///g # remove single line comments

# count not empty lines
find -name *.java | grep -c "<character>"

But I would need to do that for each file type. It seems like there should be some utility that does that already. (something mac/unix compatible would be preferable).


Use CLOC.. it is written in Perl and it supports almost every programming language, it's easily configurable and very fast.


One of my favorite tools to count SLOC is cloc, written in Perl. Without any extra configuration on your part, it will tell you the number of blank lines, the number of commented lines, and the number of source lines over an entire tree of source files. It breaks down the numbers by file extension as well.


The ohloh.net website uses a nice LOC calculator for their stats, which is freely available:

https://www.ohloh.net/p/loc-calculator

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号