mrkeyoor.com_
Sat 31 Oct 17:59 UTC
Dev Toolsevaluationupdated 31 Oct 2026

cloc review

Cloc counts physical lines of source code, comments and blank lines, grouped by language. It can also compare two versions of a codebase, making it useful for repository inventories when you keep the file-selection rules consistent.

Verdict

Cloc counts embedded JavaScript as HTML when it sits inside an HTML file, so its language totals need interpretation on mixed-language projects. It is worth evaluating for a repeatable source inventory with explicit exclusions and spot checks. We have no execution result for cloc because Perl was outside our harness’s supported ecosystems, and cannot recommend it on measured speed or accuracy.

We ran it

Screenshot of cloc (github.com/AlDanial/cloc)

Answers from our run

Did you run cloc yourself?

No. Its code is Perl, and it carries no manifest our lab installs from, so there was nothing standard to install, build or test. This review is written from the repository's own documentation.

Who should not use cloc?

Teams needing separate embedded-language totals: the README says JavaScript inside an HTML file is counted as HTML.

What are the alternatives to cloc?

Tokei, scc. Cloc counts embedded JavaScript as HTML when it sits inside an HTML file, so its language totals need interpretation on mixed-language projects.

SetupN/ANot assessed: installation was not reproduced because Perl was outside the lab harness’s supported ecosystems.
Docs4/5The README documents input selection, report formats, comparison modes and concrete counting limitations. The instructions were inspected without execution.
CommunityN/ARecent issue and pull-request activity is visible, but this inspection does not establish support response times or maintainer capacity.
MaturityN/AThe release history and documented limitations are useful evidence, but no local execution or counting-accuracy check supports a numerical maturity judgment.

Who it’s for

Maintainers who need a source inventory with explicit exclusions and per-file inspection.
Teams comparing repository snapshots with the same counting rules.
Developers who want machine-readable line counts and can spot-check files whose syntax may confuse the counter.

Who it’s NOT for

Teams needing separate embedded-language totals: the README says JavaScript inside an HTML file is counted as HTML.
Audits requiring contextual interpretation of Python docstrings: cloc treats them as comments by default, and its override treats all of them as code.
Anyone requiring compiler-level syntax interpretation: the README says cloc does not parse the languages it counts and documents comment-classification errors.

Setup reality

We did not run cloc. The October 29, 2026 lab record at f46c2c1 says Perl was outside the harness’s supported ecosystems, so it provides no installation, build or test result. The scan found a Dockerfile. That is a harness boundary, not evidence that cloc failed.

The README documents a Perl source route, a Windows executable and Docker. The source route needs a Perl interpreter, and Docker needs an available Docker installation. Counting local files does not require a hosted account. Git-based selection needs the relevant local Git tooling.

The recorded sandbox configuration listed 3 CPUs and 8 GB RAM, with image marked n/a. No actual runtime or operating-system version is established. Choose a documented route and verify it on your target platform before relying on its output.

Cloc's totals depend on what you ask it to count

Cloc separates physical source lines, comments and blanks into a language report. Pointing it at a repository can answer a useful maintenance question: what source is here, and how has that inventory changed? The answer becomes less useful if generated files enter one report and disappear from the next.

The README documents directory exclusions, Git-based file selection and per-file output. Those controls are the reason to consider cloc for an inventory. Before adopting a total as a baseline, decide whether vendored code and generated assets belong in it. The counting command should preserve that decision alongside the report.

Physical lines also need a careful label. Reformatting a file can change its line count without adding behavior. A repository inventory is useful context for a migration or cleanup, but the total alone cannot establish engineering effort, maintainability or the value of a contributor's work.

What happened when we ran it

The October 29, 2026 lab record contains no execution result for cloc at commit f46c2c1: Perl was outside the harness's supported ecosystems. We did not run it, and have no installation duration, build result, passing-test count or throughput measurement to report. The scan did find a Dockerfile.

The recorded sandbox configuration listed 3 CPUs and 8 GB RAM, with the image field marked n/a. Neither that configuration nor the Dockerfile establishes a working deployment route. This boundary belongs to our harness, so it would be wrong to describe the missing run as a cloc failure.

The documentation describes a Perl source route, a Windows executable and Docker. These give a prospective user places to start, without supplying an independently verified setup outcome here. Choose the route you intend to use and check a small set of files whose expected classification you can inspect by hand.

Keep file selection with the report

Cloc's documented --vcs=git option invokes Git to obtain a file list. --exclude-dir omits named directories, while --by-file exposes individual results. That combination gives you a way to investigate a surprising total instead of accepting the language summary as a complete explanation.

For a tracked-source inventory, the following is a documentation-based starting point, not a command reproduced in our lab:

cloc --vcs=git --exclude-dir=vendor,dist --by-file --json

Here, excluding vendor and dist is an example policy. Use the directories that match your repository and intended question. If the review is about everything you distribute, excluding vendored code may be inappropriate. Check the file list before deciding the command answers your question.

The README also documents duplicate-file handling and an option to skip its uniqueness check. Identical copies can therefore affect how you interpret the output. Keep that policy stable when comparing snapshots, along with the cloc version and selected revision. Otherwise a change in counting rules can look like a change in source size.

Embedded languages and docstrings can change the interpretation

The limitations section says embedded languages are not recognized: JavaScript inside an HTML file is counted entirely as HTML. For a project with substantial inline scripts, the language report therefore describes cloc's classification of files rather than a precise division of every language used within them.

Python docstrings create another explicit boundary. By default cloc treats all docstrings as comments, and --docstring-as-code treats all of them as code. It does not infer their meaning from context. Choose a convention that matches the report's purpose and record it, especially if someone will compare the result with another counter.

The README warns about comment markers inside strings and nested comments, and says cloc does not parse the languages it counts. These are substantive reasons to walk away if an audit demands syntax-aware accuracy. For an approximate inventory, they are reasons to inspect representative tricky files before trusting the aggregate.

Comparison mode is useful when the rules stay fixed

Cloc documents comparing two versions of a codebase and reporting differences in blank, comment and source lines. That can support a review of repository changes if the inputs and exclusions stay consistent. It does not tell you whether an added line is useful, whether a deletion removed a defect or whether a rewrite is easier to maintain.

Tokei is worth evaluating when code counting needs to live inside another application: its README documents a library interface. scc adds complexity and cost estimates to counting. Neither alternative has a comparative result in this review. Use the same representative files to judge classification differences, rather than treating unlike totals as evidence that one counter is faster or more accurate.

Recent maintenance does not replace an accuracy check

GitHub recorded cloc's last push on October 26, 2026. The recent activity feed included parsing-related issues and pull requests updated that day. The latest release endpoint returned v2.10, published July 4, 2026. The later push and issue activity provide evidence of work beyond that release, without establishing that every reported parsing problem is fixed.

Documentation receives 4 on an editorial scale where 1 means major practical omissions, 3 means usable guidance with material gaps, and 5 means detailed guidance independently corroborated within the assessed scope. The README explains both controls and known counting limitations. Setup, community support and operational maturity remain unassessed, rather than receiving invented middle scores.

Save the chosen revision, exclusions and docstring policy with your first report. When a later total changes unexpectedly, inspect the affected files before turning the number into a claim about the project.

Alternatives

ProjectWhat it isPick it when
TokeiA code-statistics tool that also exposes its functionality as a library.Choose it when embedding code counting in another application matters. Check its treatment of your languages with the same sample files before changing counters.
sccA code counter that also offers complexity and cost estimates.Choose it when you want those additional estimates in the same report, while treating estimates separately from measured development effort.

What people are saying

  1. [velocity-scout] AlDanial/cloc

Sources

  1. Cloc README and limitations
  2. Cloc repository facts
  3. Cloc recent issue activity
  4. Cloc latest release
  5. Tokei README
  6. scc README

More dev tools reviews

rufus · linux-insides · cat-catch · date-fns · okhttp · the-craft-of-selfteaching · the whole board →