문제

I'm trying to count the total lines of code, and most importantly the lines of comments!

I am currently using eclipse, and I have tried metrics2 for eclipse but it only gives total lines of code, which ignores whitespace and comments.

Could anyone suggest how I can get this value please

Thanks

도움이 되었습니까?

해결책

You can try cloc. It is simple to use and supports a bunch of languages.

다른 팁

CodePro Analytix is an Eclipse plug-in that collects Java metrics including counting comments.

If you need this only once, and you don't mind it being slightly wrong, you can use a regular expression to hunt for comment start indicators, and simply count the number of hits. My unix is bit rusty, but I think you want something like

grep -r '.*/[\*/]' yourdirectory | wc

This finds lines that apparantly have a comment start in them, and then "counts". wc produces three numbers: line count, word count, character count; the first value is line count and corresponds to the number of hits, therefore the number of comments encountered.

If you want the number of comment lines, this will badly undercount multiline /* ... */ comments; you'll get a lower bound. But then, you wanted a fast answer.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top