How to Install and Use scc in Linux to Count Lines of Code and Calculate Project Complexity

When assessing new repositories, auditing legacy codebases, or planning refactoring sprints, developers frequently need to quantify lines of source code, comments, whitespace, and algorithmic complexity. While classic utilities like cloc and modern tools like tokei provide valuable metrics, scc (Sloc, Cloc and Code) stands out as an exceptionally fast, feature-rich source code analysis tool written in Go. In addition to counting raw lines, scc calculates cyclomatic complexity and estimates project development schedules and financial costs using the established COCOMO II estimation model.

Key Features of scc

Written from the ground up for extreme concurrency and minimal overhead, scc offers notable performance advantages:

  • Blazing Execution Speed: Processes large-scale source trees (hundreds of thousands of files) in fractions of a second across multi-core processors.
  • Extensive Language Support: Accurately identifies over 400 programming languages, configuration formats, markup dialects, and embedded script tags.
  • Cyclomatic Complexity Scoring: Identifies code blocks with high branching and nested logic, helping engineering teams pinpoint maintainability bottlenecks.
  • COCOMO II Estimation: Automatically calculates estimated person-months and monetary costs required to build or replace the codebase.
  • Multiple Output Formats: Generates formatted terminal tables, JSON, CSV, SQL, or HTML reports for integration into continuous integration (CI) pipelines.

How to Install scc on Linux

You can install scc through various package managers or directly via Go:

Distribution / Environment Installation Command
Go (Cross-Platform) go install github.com/boyter/scc/v3@latest
Snap (Ubuntu / Debian / Fedora) sudo snap install scc
Arch Linux / Manjaro sudo pacman -S scc
Homebrew on Linux brew install scc

To verify that the installation succeeded, check the installed binary version:

scc --version

Running a Basic Codebase Scan

To analyse a software project, navigate into the repository root and invoke scc without arguments:

cd /path/to/project
scc

The terminal immediately displays a tabular summary organised by language, detailing total files, lines of code (SLOC), comments, blank lines, cyclomatic complexity, and aggregate totals.

Advanced Usage and Useful Command Options

Tailor your code audits with these practical flags and workflow recipes:

1. Sort Output by Specific Metrics

By default, scc sorts languages alphabetically. To prioritise languages by total lines of code or complexity, use the --sort flag:

scc --sort lines
scc --sort complexity

2. Adjust COCOMO Wage and Schedule Estimates

To calculate financial estimates that match your development team’s real-world cost benchmarks, customise the average annual salary and project overhead:

scc --avg-wage 95000

The bottom summary row will calculate the estimated project effort in person-months alongside the projected financial investment.

3. Export Results to JSON or CSV for CI/CD Auditing

Exporting machine-readable reports is straightforward when tracking codebase growth over time:

scc -f json -o metrics.json
scc -f csv -o code_audit.csv

4. Exclude Vendor Directories and Generated Assets

To ensure third-party libraries do not distort your internal development metrics, pass exclusion patterns:

scc --exclude-dir node_modules,vendor,dist,build

Incorporating scc into Development Workflows

Running scc prior to quarterly code reviews provides quantitative visibility into technical debt, language sprawl, and file maintenance requirements. Because it runs locally and requires zero network access, it remains completely safe for proprietary and air-gapped repositories.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.