Introduce a useful code statistics tool

If you want to know the code size of the project, get statistics such as the number of classes, code lines, etc., just use cloc, very good, very powerful.
You can learn more about it here.
http://cloc.sourceforge.net/

cloc supports almost any OS and automatically recognizes code in multiple languages ​​(C++, Java, JavaScript, SQL, CSS, etc.), of course, including Windows, if it is Windows, download the EXE file directly (http://sourceforge.net/projects/cloc/), setting a PATH environment variable can be used.

  >cloc <project folder>

  You can get the statistics of the code:

  you can also write the statistics to a file (different formats are supported)
cloc ridge --report-file=f:\ridge.csv --csv

   The above command writes the code statistics of the ridge project to a file in csv format.

If you want to exclude certain files (such as some JS files are third-party, such as JQuery, etc.), you can pass
quote
--exclude-list-file=<file>  Ignore files and/or directories whose names
                          appear in <file>.  <file> should have one entry
                          per line.  Relative path names will be resolved
                          starting from the directory where cloc is
                          invoked.  See also --list-file.

Option to exclude, each line in excludeFiles.txt corresponds to a file being excluded:
quote

jquery.js
kendo.js
...

cloc ridge --exclude-list-file e:\excludeFiles.txt


Under normal circumstances, these third-party JS should be placed in a unified directory, such as js/lib, then you can pass
quote
--exclude-dir=<D1>[,D2,]

The following command excludes all files in the lib folder and generates a statistical report into a csv:
clock. --exclude-dir = lib --csv --report-file = e: \ euler.csv

The help information for cloc is very rich and can be accessed through:
cloc --help

Check it out.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326452204&siteId=291194637