Count lines of code

Cloc

is in Debian repos.

cloc counts blank lines, comment lines, and physical lines of source code in many programming languages.

Example output (for this blog):

time cloc .
    2737 text files.
    2688 unique files.
     327 files ignored.

github.com/AlDanial/cloc v 1.96  T=58.15 s (46.2 files/s, 8140.3 lines/s)
-------------------------------------------------------------------
Language         files          blank        comment           code
-------------------------------------------------------------------
SVG                110           9111             59         391601
Markdown          2523          11933             54          49460
HTML                28           1554            134           4501
CSS                 12            519            659           2335
JavaScript           4             95             51            588
Text                 5             35              0            222
JSON                 1             15              0            213
YAML                 2              6              4             76
Python               1              9              7             35
XML                  1              4              0             23
Ruby                 1              7              0             22
-------------------------------------------------------------------
SUM:              2688          23288            968         449076
-------------------------------------------------------------------
cloc .  2.61s user 6.78s system 16% cpu 58.311 total

Tokei (rust)

Installed with cargo:

cargo install tokei

Tokei is a program that displays statistics about your code. Tokei will show the number of files, total lines within those files and code, comments, and blanks grouped by language.

returns:

time tokei .
=======================================================================
 Language    Files        Lines         Code     Comments       Blanks
=======================================================================
 CSS            14         3582         2401          660          521
 JavaScript      4          734          588           51           95
 JSON            1          228          213            0           15
 Python          1           51           43            1            7
 Ruby            1           29           21            1            7
 SVG           112       408071       398899           59         9113
 Plain Text      5          257            0          222           35
 XML             1           27           23            0            4
 YAML            2           86           76            4            6
-----------------------------------------------------------------------
 HTML           28         5707         4127          129         1451
 |- CSS          9          277          208            3           66
 |- JavaScript   2          209          201            3            5
 (Total)                   6193         4536          135         1522
-----------------------------------------------------------------------
 Markdown     2524        61209            0        49306        11903
 |- BASH         2           40           19           11           10
 |- Clojure      1           17           13            0            4
 |- CSS          1           21           16            2            3
 |- Lua          1           27           19            2            6
 |- Ruby         1          173          108           52           13
 (Total)                  61487          175        49373        11939
=======================================================================
 Total        2693       479981       406391        50433        23157
=======================================================================
tokei .  1.01s user 22.07s system 597% cpu 3.862 total

Don’t know where it found clojure, but look at the speed!

SCC (go)

Install, download the precompiled go binary or
https://github.com/boyter/scc

Goal is to be the fastest code counter possible, but also perform COCOMO calculation like sloccount and to estimate code complexity similar to cyclomatic complexity calculators. In short one tool to rule them all.

time scc .
──────────────────────────────────────────────────────────────────────
Language        Files     Lines   Blanks  Comments     Code Complexity
──────────────────────────────────────────────────────────────────────
Markdown         2521     61441    11933         0    49508          0
SVG               112    408071     9113        59   398899          4
HTML               28      6189     1531       129     4529          0
CSS                14      3582      521       660     2401          0
Plain Text          5       257       35         0      222          0
JavaScript          4       734       95        51      588        145
YAML                2        86        6         4       76          0
JSON                1       228       15         0      213          0
Python              1        51        7        10       34          9
Ruby                1        29        7         1       21          0
XML                 1        27        4         0       23          0
gitignore           1         5        0         0        5          0
──────────────────────────────────────────────────────────────────────
Total            2691    480700    23267       914   456519        158
──────────────────────────────────────────────────────────────────────
Estimated Cost to Develop (organic) $16,750,474
Estimated Schedule Effort (organic) 40.14 months
Estimated People Required (organic) 37.08
──────────────────────────────────────────────────────────────────────
Processed 32592782 bytes, 32.593 megabytes (SI)
──────────────────────────────────────────────────────────────────────

scc .  0.61s user 36.33s system 648% cpu 5.695 total

I knew my blog was worth something, but $16,750,474 may be a little high.

Other newish tools

https://dev.to/lissy93/cli-tools-you-cant-live-without-57f6