简单好用的跨平台代码行数统计工具

你可以用 cloc 很容易地统计多种语言的源代码行数。它还可以计算空行数、代码行数、实际代码的行数,并通过整齐的表格进行结果输出。他是一个使用Perl编写的跨平台工具。

Github地址:https://github.com/AlDanial/cloc

使用方法

win

  1. 从github上下载.exe文件
  2. 把它放在任意文件夹下
  3. 把该路径添加到环境变量里以方便我们在任何地方使用该工具。

你可以统计一个项目的代码量,也可以使用该工具得到单个文件的代码量,注释量等。
cloc 目录名/文件名

blank:空白行
comment:注释

imaginemiracle@: cloc perl-5.22.0.tar.gz
5605 text files.
5386 unique files.
2176 files ignored.

https://github.com/AlDanial/cloc v 1.65 T=25.49 s (134.7 files/s, 51980.3 lines/s)
-----------------------------------------------------------------------------------
Language files blank comment code
-----------------------------------------------------------------------------------
Perl 2892 136396 184362 536445
C 130 24676 33684 155648
C/C++ Header 148 9766 16569 147858
Bourne Shell 112 4044 6796 42668
Pascal 8 458 1603 8592
XML 33 142 0 2410
YAML 49 20 15 2078
C++ 10 313 277 2033
make 4 426 488 1986
Prolog 12 438 2 1146
JSON 14 1 0 1037
yacc 1 85 76 998
Windows Message File 1 102 11 489
DOS Batch 14 92 41 389
Windows Resource File 3 10 0 85
D 1 5 7 8
Lisp 2 0 3 4
-----------------------------------------------------------------------------------
SUM: 3434 176974 243934 903874
-----------------------------------------------------------------------------------