关于sloc
发布于 9 年前 作者 i5ting 6876 次浏览 最后一次编辑是 8 年前 来自 分享

为什么说这个?

主要是今天我发现github单个文件有了sloc,而且最近经常用sloc npm

Screen Shot 2014-12-27 at 10.18.34 PM.png

是为故

什么是LOC?科普

软件规模代码行(LOC, Line of Code)是软件规模的一种量度,它表示源代码行数。常使用的单位有:

sloc,kloc,lloc,ploc,nloc.......

【Linux】代码统计工具sloccount

sloccount=Count Source Lines Of Code

官网:http://www.dwheeler.com/sloccount/

Ubuntu安装

sudo apt-get install sloccount

nodejs sloc

To use sloc as an application install it globally:

sudo npm install -g sloc

代码

https://github.com/flosse/sloc

剩下的自己去玩吧

sloc [option] <file>|<directory>
Options:

-h, --help                  output usage information
-V, --version               output the version number
-e, --exclude <regex>       regular expression to exclude files and folders
-f, --format <format>       format output: json, csv, cli-table
    --format-option [value] add formatter option
-k, --keys <keys>           report only numbers of the given keys
-d, --details               report stats of each analzed file
-a, --alias <custom ext>=<standard ext> alias custom ext to act like standard ext (eg. php5=php,less=css)

。。。。

3 回复

用系统自带的wc不就可以了嘛

$ cat install.txt | wc -l
     245

@leapon 如果是目录呢?

➜  api-test git:(master) sloc src

---------- Result ------------

            Physical :  421
              Source :  258
             Comment :  96
 Single-line comment :  84
       Block comment :  12
               Mixed :  1
               Empty :  68

Number of files read :  4

------------------------------

嗯,sloc 功能会多一些

回到顶部