cloc

所属分类:collect
开发工具:Perl
文件大小:0KB
下载次数:0
上传日期:2023-07-08 20:46:54
上 传 者sh-1993
说明:  cloc统计许多编程语言中源代码的空白行、注释行和物理行。,
(cloc counts blank lines, comment lines, and physical lines of source code in many programming languages.,)

文件列表:
.devcontainer/ (0, 2023-12-08)
.devcontainer/Dockerfile (764, 2023-12-08)
.devcontainer/devcontainer.json (221, 2023-12-08)
.dockerignore (26, 2023-12-08)
.vscode/ (0, 2023-12-08)
.vscode/launch.json (375, 2023-12-08)
Dockerfile (938, 2023-12-08)
Dockerfile.build (65, 2023-12-08)
LICENSE (18047, 2023-12-08)
Unix/ (0, 2023-12-08)
Unix/AUTHORS (923, 2023-12-08)
Unix/COPYING (18092, 2023-12-08)
Unix/INSTALL (235, 2023-12-08)
Unix/Makefile (3483, 2023-12-08)
Unix/NEWS (49421, 2023-12-08)
Unix/cloc (630689, 2023-12-08)
Unix/cloc.1.pod (25291, 2023-12-08)
Unix/pod2man.mk (2008, 2023-12-08)
Unix/t/ (0, 2023-12-08)
Unix/t/00_C.t (56977, 2023-12-08)
Unix/t/01_opts.t (36027, 2023-12-08)
Unix/t/02_git.t (6307, 2023-12-08)
Unix/why_this_directory_exists.txt (821, 2023-12-08)
cloc (731577, 2023-12-08)
sqlite_formatter (1818, 2023-12-08)
tests/ (0, 2023-12-08)
tests/inputs/ (0, 2023-12-08)
tests/inputs/AnsProlog.lp (1047, 2023-12-08)
tests/inputs/Application_Data_Test.feature.cs (1015, 2023-12-08)
... ...

# cloc *Count Lines of Code* * * * cloc counts blank lines, comment lines, and physical lines of source code in many programming languages. Latest release: v1.98 (Aug. 19, 2023) DOI cloc moved to GitHub in September 2015 after being hosted at http://cloc.sourceforge.net/ since August 2006. * [Quick Start](https://github.com/AlDanial/cloc/blob/master/#quick-start-) * [Overview](https://github.com/AlDanial/cloc/blob/master/#overview-) * [Download](https://github.com/AlDanial/cloc/blob/master/https://github.com/AlDanial/cloc/releases/latest) * [Install via package manager](https://github.com/AlDanial/cloc/blob/master/#install-via-package-manager) * [Stable release](https://github.com/AlDanial/cloc/blob/master/#stable-release) * [Development version](https://github.com/AlDanial/cloc/blob/master/#development-version) * [License](https://github.com/AlDanial/cloc/blob/master/#license-) * [Why Use cloc?](https://github.com/AlDanial/cloc/blob/master/#why-use-cloc-) * [Other Counters](https://github.com/AlDanial/cloc/blob/master/#other-counters-) * [Building a Windows Executable](https://github.com/AlDanial/cloc/blob/master/#building-a-windows-executable-) * [Basic Use](https://github.com/AlDanial/cloc/blob/master/#basic-use-) * [Options](https://github.com/AlDanial/cloc/blob/master/#options-) * [Recognized Languages](https://github.com/AlDanial/cloc/blob/master/#recognized-languages-) * [How it Works](https://github.com/AlDanial/cloc/blob/master/#how-it-works-) * [Advanced Use](https://github.com/AlDanial/cloc/blob/master/#advanced-use-) * [Remove Comments from Source Code](https://github.com/AlDanial/cloc/blob/master/#remove-comments-from-source-code-) * [Work with Compressed Archives](https://github.com/AlDanial/cloc/blob/master/#work-with-compressed-archives-) * [Differences](https://github.com/AlDanial/cloc/blob/master/#differences-) * [Create Custom Language Definitions](https://github.com/AlDanial/cloc/blob/master/#create-custom-language-definitions-) * [Combine Reports](https://github.com/AlDanial/cloc/blob/master/#combine-reports-) * [SQL](https://github.com/AlDanial/cloc/blob/master/#sql-) * [Custom Column Output](https://github.com/AlDanial/cloc/blob/master/#custom-column-output-) * [Wrapping cloc in other scripts](https://github.com/AlDanial/cloc/blob/master/#wrapping-cloc-in-other-scripts-) * [git and UTF8 pathnames](https://github.com/AlDanial/cloc/blob/master/#git-and-UTF8-pathnames-) * [Third Generation Language Scale Factors](https://github.com/AlDanial/cloc/blob/master/#third-generation-language-scale-factors-) * [options.txt configuration file](https://github.com/AlDanial/cloc/blob/master/#optionstxt-configuration-file-) * [Complex regular subexpression recursion limit ](https://github.com/AlDanial/cloc/blob/master/#complex-regular-subexpression-recursion-limit-) * [Limitations](https://github.com/AlDanial/cloc/blob/master/#limitations-) * [Requesting Support for Additional Languages](https://github.com/AlDanial/cloc/blob/master/#requesting-support-for-additional-languages-) * [Reporting Problems](https://github.com/AlDanial/cloc/blob/master/#reporting-problems-) * [Citation](https://github.com/AlDanial/cloc/blob/master/#citation-) * [Acknowledgments](https://github.com/AlDanial/cloc/blob/master/#acknowledgments-) * [Copyright](https://github.com/AlDanial/cloc/blob/master/#copyright-) [](https://github.com/AlDanial/cloc/blob/master/{{{1) # [Quick Start ▲](https://github.com/AlDanial/cloc/blob/master/#___top "click to go to top of document") Step 1: Download cloc (several methods, see below) or run cloc's [docker image](https://github.com/AlDanial/cloc/blob/master/#run-via-docker). The Windows executable has no requirements. The source version of cloc requires a Perl interpreter, and the Docker version of cloc requires a Docker installation. Step 2: Open a terminal (`cmd.exe` on Windows). Step 3: Invoke cloc to count your source files, directories, archives, or git commits. The executable name differs depending on whether you use the development source version (`cloc`), source for a released version (`cloc-1.98.pl`) or a Windows executable (`cloc-1.98.exe`). On this page, `cloc` is the generic term used to refer to any of these. [Include Security](https://github.com/AlDanial/cloc/blob/master/https://www.youtube.com/user/IncludeSecurity) has a [YouTube video](https://github.com/AlDanial/cloc/blob/master/https://www.youtube.com/watch?v=eRLTkDMsCqs) showing the steps in action. **a file**
prompt> cloc hello.c
       1 text file.
       1 unique file.
       0 files ignored.

https://github.com/AlDanial/cloc v 1.65  T=0.04 s (28.3 files/s, 340.0 lines/s)
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
C                                1              0              7              5
-------------------------------------------------------------------------------
**a directory**
prompt> cloc gcc-5.2.0/gcc/c
      16 text files.
      15 unique files.
       3 files ignored.

https://github.com/AlDanial/cloc v 1.65  T=0.23 s (57.1 files/s, 188914.0 lines/s)
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
C                               10           4680           6621          30812
C/C++ Header                     3             99            286            496
-------------------------------------------------------------------------------
SUM:                            13           4779           6907          31308
-------------------------------------------------------------------------------
**an archive** We'll pull cloc's source zip file from GitHub, then count the contents:
prompt> wget https://github.com/AlDanial/cloc/archive/master.zip

prompt> cloc master.zip
https://github.com/AlDanial/cloc v 1.65  T=0.07 s (26.8 files/s, 141370.3 lines/s)
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
Perl                             2            725           1103           8713
-------------------------------------------------------------------------------
SUM:                             2            725           1103           8713
-------------------------------------------------------------------------------
**a git repository, using a specific commit** This example uses code from PuDB, a fantastic Python debugger.
prompt> git clone http://git.tiker.net/trees/pudb.git

prompt> cd pudb

prompt> cloc 6be804e07a5db
      48 text files.
      48 unique files.
      15 files ignored.

github.com/AlDanial/cloc v 1.73  T=0.15 s (223.1 files/s, 46159.0 lines/s)
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
Python                          28           1519            728           4659
YAML                             2              9              2             75
Bourne Shell                     3              6              0             17
make                             1              4              6             10
-------------------------------------------------------------------------------
SUM:                            34           1538            736           4761
-------------------------------------------------------------------------------

**each subdirectory of a particular directory** Say you have a directory with three different git-managed projects, Project0, Project1, and Project2. You can use your shell's looping capability to count the code in each. This example uses bash (scroll down for cmd.exe example):
prompt> for d in ./*/ ; do (cd "$d" && echo "$d" && cloc --vcs git); done
./Project0/
7 text files.
       7 unique files.
       1 file ignored.

github.com/AlDanial/cloc v 1.71  T=0.02 s (390.2 files/s, 25687.6 lines/s)
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
D                                4             61             32            251
Markdown                         1              9              0             38
make                             1              0              0              4
-------------------------------------------------------------------------------
SUM:                             6             70             32            293
-------------------------------------------------------------------------------
./Project1/
       7 text files.
       7 unique files.
       0 files ignored.

github.com/AlDanial/cloc v 1.71  T=0.02 s (293.0 files/s, 52107.1 lines/s)
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
Go                               7            165            282            798
-------------------------------------------------------------------------------
SUM:                             7            165            282            798
-------------------------------------------------------------------------------
./Project2/
      49 text files.
      47 unique files.
      13 files ignored.

github.com/AlDanial/cloc v 1.71  T=0.10 s (399.5 files/s, 70409.4 lines/s)
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
Python                          33           1226           1026           3017
C                                4            327            337            888
Markdown                         1             11              0             28
YAML                             1              0              2             12
-------------------------------------------------------------------------------
SUM:                            39           1564           1365           3945
-------------------------------------------------------------------------------
**each subdirectory of a particular directory (Windows/cmd.exe)**
for /D %I in (.\*) do cd %I && cloc --vcs git && cd ..
[](https://github.com/AlDanial/cloc/blob/master/1}}}) [](https://github.com/AlDanial/cloc/blob/master/{{{1) # [Overview ▲](https://github.com/AlDanial/cloc/blob/master/#___top "click to go to top of document") cloc counts blank lines, comment lines, and physical lines of source code in [many programming languages](https://github.com/AlDanial/cloc/blob/master/#Languages). Given two versions of a code base, cloc can compute differences in blank, comment, and source lines. It is written entirely in Perl with no dependencies outside the standard distribution of Perl v5.6 and higher (code from some external modules is [embedded within cloc](https://github.com/AlDanial/cloc/blob/master/https://github.com/AlDanial/cloc#regexp_common)) and so is quite portable. cloc is known to run on many flavors of Linux, FreeBSD, NetBSD, OpenBSD, macOS, AIX, HP-UX, Solaris, IRIX, z/OS, and Windows. (To run the Perl source version of cloc on Windows one needs [ActiveState Perl](https://github.com/AlDanial/cloc/blob/master/http://www.activestate.com/activeperl) 5.6.1 or higher, [Strawberry Perl](https://github.com/AlDanial/cloc/blob/master/http://strawberryperl.com/), Windows Subsystem for Linux, [Cygwin](https://github.com/AlDanial/cloc/blob/master/http://www.cygwin.com/), [MobaXTerm](https://github.com/AlDanial/cloc/blob/master/http://mobaxterm.mobatek.net/) with the Perl plug-in installed, or a mingw environment and terminal such as provided by [Git for Windows](https://github.com/AlDanial/cloc/blob/master/https://gitforwindows.org/). Alternatively one can use the Windows binary of cloc generated with [PAR::Packer](https://github.com/AlDanial/cloc/blob/master/http://search.cpan.org/~rschupp/PAR-Packer-1.019/lib/pp.pm) to run on Windows computers that have neither Perl nor Cygwin.) In addition to counting code in individual text files, directories, and git repositories, cloc can also count code in archive files such as ``.tar`` (including compressed versions), ``.zip``, Python wheel ``.whl``, Jupyter notebook ``.ipynb``, source RPMs ``.rpm`` or ``.src`` (requires ``rpm2cpio``), and Debian ``.deb`` files (requires ``dpkg-deb``). cloc contains code from David Wheeler's [SLOCCount](https://github.com/AlDanial/cloc/blob/master/http://www.dwheeler.com/sloccount/), Damian Conway and Abigail's Perl module [Regexp::Common](https://github.com/AlDanial/cloc/blob/master/http://search.cpan.org/%7Eabigail/Regexp-Common-2.120/lib/Regexp/Common.pm), Sean M. Burke's Perl module [Win32::Autoglob](https://github.com/AlDanial/cloc/blob/master/http://search.cpan.org/%7Esburke/Win32-Autoglob-1.01/Autoglob.pm), and Tye McQueen's Perl module [Algorithm::Diff](https://github.com/AlDanial/cloc/blob/master/http://search.cpan.org/%7Etyemq/Algorithm-Diff-1.1902/lib/Algorithm/Diff.pm). Language scale factors were derived from Mayes Consulting, LLC web site http://softwareestimator.com/IndustryData2.htm. New releases nominally appear every six months. [](https://github.com/AlDanial/cloc/blob/master/1}}}) [](https://github.com/AlDanial/cloc/blob/master/{{{1) ## Run via docker ```shell docker run --rm -v $PWD:/tmp aldanial/cloc ``` ### Run via docker on git-bash ```shell docker run --rm -v "/$(pwd -W)":/tmp aldanial/cloc ``` ## Install via package manager Depending your operating system, one of these installation methods may work for you (all but the last two entries for Windows require a Perl interpreter): 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 doas pkg_add cloc # OpenBSD sudo pkg install cloc # FreeBSD sudo port install cloc # macOS with MacPorts brew install cloc # macOS with Homebrew choco install cloc # Windows with Chocolatey scoop install cloc # Windows with Scoop **Note**: I don't control any of these packages. If you encounter a bug in cloc using one of the above packages, try with cloc pulled from the latest stable release here on GitHub (link follows below) before submitting a problem report. [](https://github.com/AlDanial/cloc/blob/master/1}}}) [](https://github.com/AlDanial/cloc/blob/master/{{{1) ## Stable release https://github.com/AlDanial/cloc/releases/latest ## Development version https://github.com/AlDanial/cloc/raw/master/cloc [](https://github.com/AlDanial/cloc/blob/master/1}}}) [](https://github.com/AlDanial/cloc/blob/master/{{{1) # [License ▲](https://github.com/AlDanial/cloc/blob/master/#___top "click to go to top of document") cloc is licensed under the [GNU General Public License, v 2](https://github.com/AlDanial/cloc/blob/master/http://www.gnu.org/licenses/gpl-2.0.html), excluding portions which are copied from other sources. Code copied from the Regexp::Common, Win32::Autoglob, and Algorithm::Diff Perl modules is subject to the [Artistic License](https://github.com/AlDanial/cloc/blob/master/https://opensource.org/license/artistic-2-0). [](https://github.com/AlDanial/cloc/blob/master/1}}}) [](https://github.com/AlDanial/cloc/blob/master/{{{1) # [Why Use cloc? ▲](https://github.com/AlDanial/cloc/blob/master/#___top "click to go to top of document") cloc has many features that make it easy to use, thorough, extensible, and portable: 1. Exists as a single, self-contained file that requires minimal installation effort---just download the file and run it. 2. Can read language comment definitions from a file and thus potentially work with computer languages that do not yet exist. 3. Allows results from multiple runs to be summed together by language and by project. 4. Can produce results in a variety of formats: plain text, SQL, JSON, XML, YAML, comma separated values. 5. Can count code within compressed archives (tar balls, Zip files, Java .ear files). 6. Has numerous troubleshooting options. 7. Handles file and directory names with spaces and other unusual characters. 8. Has no dependencies outside the standard Perl distribution. 9. Runs on Linux, FreeBSD, NetBSD, OpenBSD, macOS, AIX, HP-UX, Solaris, IRIX, and z/OS systems that have Perl 5.6 or higher. The source version runs on Windows with either ActiveState Perl, Strawberry Perl, Cygwin, or MobaXTerm+Perl plugin. Alternatively on Windows one can run the Windows binary which has no dependencies. [](https://github.com/AlDanial/cloc/blob/master/1}}}) [](https://github.com/AlDanial/cloc/blob/master/{{{1) # [Other Counters ▲](https://github.com/AlDanial/cloc/blob/master/#___top "click to go to top of document") If cloc does not suit your needs here are other freely available counters to consider: * [loc](https://github.com/AlDanial/cloc/blob/master/https://github.com/cgag/loc/) * [gcloc](https://github.com/AlDanial/cloc/blob/master/https://github.com/JoaoDanielRufino/gcloc) * [gocloc](https://github.com/AlDanial/cloc/blob/master/https://github.com/hhatto/gocloc/) * [Ohcount](https://github.com/AlDanial/cloc/blob/master/https://github.com/blackducksoftware/ohcount/) * [scc](https://github.com/AlDanial/cloc/blob/master/https://github.com/boyter/scc/) * [sclc](https://github.com/AlDanial/cloc/blob/master/https://code.google.com/archive/p/sclc/) * [SLOCCount](https://github.com/AlDanial/cloc/blob/master/http://www.dwheeler.com/sloccount/) * [Sonar](https://github.com/AlDanial/cloc/blob/master/http://www.sonarsource.org/) * [tokei](https://github.com/AlDanial/cloc/blob/master/https://github.com/Aaronepower/tokei/) * [Unified Code Count](https://github.com/AlDanial/cloc/blob/master/http://csse.usc.edu/ucc_new/wordpress/) Other references: * QSM's [directory](https://github.com/AlDanial/cloc/blob/master/http://www.qsm.com/CodeCounters.html) of code counting tools. * The [Wikipedia entry](https://github.com/AlDanial/cloc/blob/master/http://en.wikipedia.org/wiki/Source_lines_of_code) for source code line counts. [](https://github.com/AlDanial/cloc/blob/master/1}}}) # Regexp::Common, Digest::MD5, Win32::Autoglob, Algorithm::Diff [](https://github.com/AlDanial/cloc/blob/master/{{{1) Although cloc does not need Perl modules outside those found in the standard distribution, cloc does rely on a few external modules. Code from three of these external modules--Regexp::Common, Win32::Autoglob, and Algorithm::Diff--is embedded within cloc. A fourth module, Digest::MD5, is used only if it is available. If cloc finds Regexp::Common or Algorithm::Diff installed locally it will use those installation. If it doesn't, cloc will install the parts of Regexp::Common and/or Algorithm:Diff it needs to temporary directories that are created at the start of a cloc run then removed when the run is complete. The necessary code from Regexp::Common v2.120 and Algorithm::Diff v1.1902 are embedded within the cloc source code (see subroutines `Install_Regexp_Common()` and `Install_Algorithm_Diff()` ). Only three lines are needed from Win32::Autoglob and these are included directly in cloc. Additionally, cloc will use Digest::MD5 to validate uniqueness among equally-sized input files if Digest::MD5 is installed locally. A parallel processing option, --processes=N, was introduced with cloc version 1.76 to enable faster runs on multi-core machines. However, to use it, one must have the module Parallel::ForkManager installed. This module does not work reliably on Windows so parallel processing will only work on Unix-like operating systems. The Windows binary is built on a computer that has both Regexp::Common and Digest::MD5 installed locally. [](https://github.com/AlDanial/cloc/blob/master/1}}}) [](https://github.com/AlDanial/cloc/blob/master/{{{1) # [Building a Windows Executable ▲](https://github.com/AlDanial/cloc/blob/master/#___top "click to go to top of document") #### Create your own executable The most robust option for creating a Windows executable of cloc is to use [ActiveState's Perl Development Kit](https://github.com/AlDanial/cloc/blob/master/http://www.activestate.com/perl-dev-kit). It includes a utility, `perlapp`, which can build stand-alone Windows, Mac, and Linux binaries of Perl source code. [perl2exe](https://github.com/AlDanial/cloc/blob/master/http://www.indigostar.com/perl2exe/) will also do the trick. If you do have `perl2exe`, modify lines 84-87 in the cloc source code for a minor code modification that is necessary to make a cloc Windows executable. Otherwise, to build a Windows executable with `pp` from `PAR::Packer`, first install a Windows-based Perl distribution (for example Strawberry Perl or ActivePerl) following their instructions. Next, open a command prompt, aka a DOS window and install the PAR::Packer module. Finally, invoke the newly installed `pp` command with the cloc source code to create an `.exe` file:
C:> cpan -i Digest::MD5
C:> cpan -i Regexp::Common
C:> cpan -i Algorithm::Diff
C:> cpan -i PAR::Packer
C:> cpan -i Win32::LongPath
C:> pp -M Win32::LongPath -M Encode::Unicode -M Digest::MD5 -c -x -o cloc-1.98.exe cloc-1.98.pl
A variation on the instructions above is if you installed the portable version of Strawberry Perl, you will need to run `portableshell.bat` first to properly set up your environment. The Windows executable in the Releases section, cloc-1.98.exe, was built on a 64 bit Windows 10 computer using [Strawberry Perl](https://github.com/AlDanial/cloc/blob/master/http://strawberryperl. ... ...

近期下载者

相关文件


收藏者