背景
需要找一款代码行统计工具,来和客户协商,多少代码行出现多少bug的问题。
使用
安装:
brew install cloc
统计使用
cloc /Users/zhangyalin/Downloads/xxxx
2309 text files.
2063 unique files.
286 files ignored.
github.com/AlDanial/cloc v 1.90 T=3.63 s (559.5 files/s, 51688.8 lines/s)
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
Java 1449 16659 21848 74430
XML 532 2635 238 66965
Markdown 2 10 0 1661
SQL 22 44 53 747
YAML 13 25 60 689
Maven 4 45 9 602
Bourne Shell 1 33 62 227
DOS Batch 1 35 0 147
JSON 2 8 0 125
diff 2 2 36 52
Dockerfile 1 0 0 4
-------------------------------------------------------------------------------
SUM: 2029 19496 22306 145649
-------------------------------------------------------------------------------
很容易,输入对应工程路径就可以了。
cloc能识别的语言可以通过命令查询:cloc --show-lang
例子
下面是一个统计java工程和一个vue工程的代码行示例。
# 统计java项目
cloc /Users/zhangyalin/Documents/...
# 统计vue项目,需要忽略第三方库依赖文件
cloc --exclude-dir=node_modules /Users/zhangyalin/Documents/...