利用cloc来统计github仓库的代码的行数

写了一段时间的代码,建了几个仓库,想知道写了多少行代码,这里利用colc来进行统计,github地址为:

https://github.com/AlDanial/cloc

我的是mac系统,安装很简单,用brew安装。

brew install cloc

其他的安装方式我这里贴一下,根据自己电脑情况选择就行了,也比较简单:

npm install -g cloc                    # https://www.npmjs.com/package/cloc
sudo apt install cloc                  # Debian, Ubuntu
sudo yum install cloc                  # Red Hat, Fedora
sudo dnf install cloc                  # Fedora 22 or later
sudo pacman -S cloc                    # Arch
sudo emerge -av dev-util/cloc          # Gentoo https://packages.gentoo.org/packages/dev-util/cloc
sudo apk add cloc                      # Alpine Linux
sudo pkg install cloc                  # FreeBSD
sudo port install cloc                 # Mac OS X with MacPorts
brew install cloc                      # Mac OS X with Homebrew
choco install cloc                     # Windows with Chocolatey
scoop install cloc                     # Windows with Scoop

然后把你的仓库从github上下载下来,解压到某个目录,然后利用cloc命令来计算,我这里给出一个我的例子:

cloc EtCampusService # 文件夹名

我的输出为:

 50342 text files.
   39823 unique files.
   15726 files ignored.

10 errors:
Line count, exceeded timeout:  EtCampusService/web/node_modules/@angular/common/esm5/http/src/xhr.js
Line count, exceeded timeout:  EtCampusService/web/node_modules/@schematics/angular/application/index.js
Line count, exceeded timeout:  EtCampusService/web/node_modules/@schematics/angular/e2e/index.js
Line count, exceeded timeout:  EtCampusService/web/node_modules/acorn/dist/acorn_loose.es.js
Line count, exceeded timeout:  EtCampusService/web/node_modules/acorn/dist/acorn_loose.js
Line count, exceeded timeout:  EtCampusService/web/node_modules/fsevents/node_modules/needle/lib/needle.js
Line count, exceeded timeout:  EtCampusService/web/node_modules/ng-alain/application/index.js
Line count, exceeded timeout:  EtCampusService/web/node_modules/ng-alain/application/index.ts
Line count, exceeded timeout:  EtCampusService/web/node_modules/socket.io-client/dist/socket.io.js
Line count, exceeded timeout:  EtCampusService/web/node_modules/tslint/lib/test.js

github.com/AlDanial/cloc v 1.80  T=105.09 s (333.3 files/s, 54599.6 lines/s)
---------------------------------------------------------------------------------------
Language                             files          blank        comment           code
---------------------------------------------------------------------------------------
JavaScript                           20953         306670         964646        3191942
JSON                                  2799            577              0         249942
Markdown                              2236          97753              2         233491
TypeScript                            6266          14436         103777         161641
CSS                                    169            658           2593          67402
XML                                    320           3254           1309          60789
HTML                                   728          49832            502          53745
LESS                                   715           6627           2371          49276
C++                                     75           3782           3505          22383
Python                                  52           4222           7606          18725
C/C++ Header                           101           2760           1857          15099
Java                                   185           1819           2078           8060
YAML                                   220            173            188           5260
Scala                                   29            918            627           3779
Bourne Shell                            25            469            463           2406
SQL                                      3            243              0           1345
make                                    37            273             61            849
Bourne Again Shell                      18            151             63            636
Windows Module Definition                6            111              0            608
DTD                                      1            179            177            514
XSLT                                     2             35             16            500
Sass                                    44             56             61            277
Lisp                                     3             42             38            264
m4                                       2             39              2            260
C#                                       3             58              8            238
CoffeeScript                            14             68             53            190
Stylus                                   1             91             39            167
XHTML                                    4              3              5            161
JSON5                                    2              0              0            123
C                                        2             24             25            113
DOS Batch                                6             38              7            107
Handlebars                               4             18              0             96
Perl                                     1             16             30             57
Windows Resource File                    1              1              1             33
ASP.NET                                  2              5              0             23
Ruby                                     1              0              2              4
---------------------------------------------------------------------------------------
SUM:                                 35030         495401        1092112        4150505
---------------------------------------------------------------------------------------

参考文献

[1].代码统计工具COLC. https://fyting.iteye.com/blog/226339

[2].cloc. http://cloc.sourceforge.net/

你可能感兴趣的:(linux学习)