A tool similar to cloc, sloccount and tokei. For counting physical the lines of code, blank lines, comment lines, and physical lines of source code in many programming languages.
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.
Also it has a very short name which is easy to type scc
.
If you don't like sloc cloc and code feel free to use the name Succinct Code Counter
.
Dual-licensed under MIT or the UNLICENSE.
If you are comfortable using Go and have >= 1.17 installed:
go install github.com/boyter/scc@latest
or bleeding edge with
go install github.com/boyter/scc@master
A snap install exists thanks to Ricardo.
$ sudo snap install scc
NB Snap installed applications cannot run outside of /home
https://askubuntu.com/questions/930437/permission-denied-error-when-running-apps-installed-as-snap-packages-ubuntu-17 so you may encounter issues if you use snap and attempt to run outside this directory.
Or if you have homebrew installed
$ brew install scc
Or if you are using Scoop on Windows
$ scoop install scc
Or if you are using Chocolatey on Windows
$ choco install scc
Binaries for Windows, GNU/Linux and macOS for both i386 and x86_64 machines are available from the releases page.
https://github.com/marketplace/actions/scc-docker-action https://github.com/iRyanBell/scc-docker-action
.github/workflows/main.yml
on: [push]
jobs:
scc_job:
runs-on: ubuntu-latest
name: A job to count the lines of code.
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Get the lines of code.
id: scc
uses: iryanbell/scc-docker-action@v1.0.2
with:
args: ${{ env.workspace }} -i js,go,html,css
If you would like to assist with getting scc
added into apt/chocolatey/etc... please submit a PR or at least raise an issue with instructions.
Read all about how it came to be along with performance benchmarks,
- https://boyter.org/posts/sloc-cloc-code/
- https://boyter.org/posts/why-count-lines-of-code/
- https://boyter.org/posts/sloc-cloc-code-revisited/
- https://boyter.org/posts/sloc-cloc-code-performance/
- https://boyter.org/posts/sloc-cloc-code-performance-update/
Some reviews of scc
- https://nickmchardy.com/2018/10/counting-lines-of-code-in-koi-cms.html
- https://www.feliciano.tech/blog/determine-source-code-size-and-complexity-with-scc/
- https://metaredux.com/posts/2019/12/13/counting-lines.html
A talk given at the first GopherCon AU about scc
(press S to see speaker notes)
For performance see the Performance section
Other similar projects,
- SLOCCount the original sloc counter
- cloc, inspired by SLOCCount; implemented in Perl for portability
- gocloc a sloc counter in Go inspired by tokei
- loc rust implementation similar to tokei but often faster
- loccount Go implementation written and maintained by ESR
- ployglot ATS sloc counter
- tokei fast, accurate and written in rust
- sloc coffeescript code counter
Interesting reading about other code counting projects tokei, loc, polyglot and loccount
- https://www.reddit.com/r/rust/comments/59bm3t/a_fast_cloc_replacement_in_rust/
- https://www.reddit.com/r/rust/comments/82k9iy/loc_count_lines_of_code_quickly/
- http://blog.vmchale.com/article/polyglot-comparisons
- http://esr.ibiblio.org/?p=8270
Further reading about processing files on the disk performance
Using scc
to process 40 TB of files from Github/Bitbucket/Gitlab
Why use scc
?
- It is very fast and gets faster the more CPU you throw at it
- Accurate
- Works very well across multiple platforms without slowdown (Windows, Linux, macOS)
- Large language support
- Can ignore duplicate files
- Has complexity estimations
- You need to tell the difference between Coq and Verilog in the same directory
- cloc yaml output support so potentially a drop in replacement for some users
- Can identify or ignore minified files
- Able to identify many #! files ADVANCED! boyter#115
- Can ignore large files by lines or bytes
Why not use scc
?
- You don't like Go for some reason
- It cannot count D source with different nested multi-line comments correctly boyter#27