LinuxCommandLibrary

scc

Count lines of code in files

TLDR

Print lines of code in the current directory

$ scc
copy

Print lines of code in the target directory
$ scc [path/to/directory]
copy

Display output for every file
$ scc --by-file
copy

Display output using a specific output format (defaults to tabular)
$ scc [[-f|--format]] [tabular|wide|json|csv|cloc-yaml|html|html-table]
copy

Only count files with specific file extensions
$ scc [[-i|--include-ext]] [go,java,js]
copy

Exclude directories from being counted
$ scc --exclude-dir [.git,.hg]
copy

Display output and sort by column (defaults to by files)
$ scc [[-s|--sort]] [files|name|lines|blanks|code|comments|complexity]
copy

Display help
$ scc [[-h|--help]]
copy

SYNOPSIS

scc [OPTIONS] [PATH...]

PATH specifies the directories or files to analyze. If no path is provided, scc processes the current directory.

PARAMETERS

--by-file
    Display results for each individual file.

-c, --config
    Specify a custom configuration file.

--count-as
    Treat files as if they belong to a specific language.

-d, --debug
    Enable verbose debug output.

-e, --exclude
    Exclude files or directories matching the given pattern.

-f, --format
    Set the output format (e.g., plain, json, csv, html).

-h, --help
    Display help information and exit.

-i, --include
    Include files or directories matching the given pattern.

-l, --languages
    List all supported programming languages.

--no-group
    Do not group results by language.

--no-gitignore
    Ignore .gitignore files when scanning.

-o, --output
    Write the command output to a specified file.

-s, --sort
    Sort results by a specific field (e.g., lines, code, comments, blanks).

-t, --top
    Limit the output to the top N languages or files.

-v, --version
    Display the version of scc and exit.

DESCRIPTION

scc (Source Code Count) is a powerful, fast command-line utility designed for accurately counting source code lines across a multitude of programming languages. It meticulously categorizes lines into code, blank, and comment lines, providing valuable insights into codebase size and complexity. Built with performance in mind using Go, scc efficiently processes large projects, offering various output formats like plain text, JSON, and CSV. It serves as an essential tool for developers, project managers, and auditors needing to quickly assess software projects. Its extensive language support and configurable options make it highly adaptable to diverse development environments.

CAVEATS

scc is not a standard utility pre-installed on most Linux distributions; it usually requires manual installation. While highly accurate, the parsing of complex or custom language constructs might occasionally lead to minor discrepancies. Its performance benefits are most noticeable on large codebases due to its concurrent design.

INSTALLATION

scc can typically be installed via Go's package manager (e.g., go install github.com/boyter/scc/v3@latest) or, less commonly, through distribution-specific repositories.

PERFORMANCE

Renowned for its exceptional speed, scc leverages Go's concurrency features to efficiently scan and analyze large code repositories, often outperforming similar tools.

HISTORY

scc emerged as a modern, Go-language based alternative to older code counting tools. Its development by Ben Boyter focused on achieving significantly faster performance and broader language support, aiming to provide a robust solution for large-scale code analysis.

SEE ALSO

cloc(1), wc(1)

Copied to clipboard