LinuxCommandLibrary

cpplint

Google C++ style guide checker

TLDR

Check single file

$ cpplint [file.cpp]
copy
Check multiple files
$ cpplint [file1.cpp] [file2.cpp]
copy
Recursive directory check
$ cpplint --recursive [src/]
copy
Filter specific categories
$ cpplint --filter=-whitespace,+build [file.cpp]
copy
Set line length
$ cpplint --linelength=[120] [file.cpp]
copy
Output in different format
$ cpplint --output=[vs7] [file.cpp]
copy

SYNOPSIS

cpplint [options] files

DESCRIPTION

cpplint is a static code checker for C++ that verifies code against Google's C++ style guide. It checks for style errors, formatting issues, and common programming mistakes to enforce consistent code standards across projects.
The tool examines source files for compliance with naming conventions, spacing rules, comment formatting, header guard patterns, and many other style requirements. It helps teams maintain uniform code style and catch common errors before code review.
Originally developed by Google for internal use, cpplint is now maintained as an open-source project. While designed specifically for Google's style guide, its rules can be filtered and customized for projects with different conventions.

PARAMETERS

--recursive

Check files in subdirectories recursively
--filter=-/+categories
Enable/disable specific warning categories
--linelength=length
Maximum line length (default 80)
--extensions=list
File extensions to process
--headers=list
Header file extensions
--output=format
Output format: emacs, vs7, eclipse, junit, sed, gsed
--counting=type
Count errors: total, toplevel, detailed
--root=dir
Project root for header guard paths
--exclude=pattern
Exclude files matching pattern

CONFIGURATION

CPPLINT.cfg

Project-wide configuration file for filters, line length, root directory, and excluded paths.

FILTER CATEGORIES

- build: Build-related issues
- legal: Copyright/license issues
- readability: Code readability
- runtime: Runtime issues
- whitespace: Spacing and formatting
Prefix with - to disable, + to enable.

CAVEATS

Designed specifically for Google style guide compliance. Some rules may not apply to all projects. Use CPPLINT.cfg file for project-wide configuration.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community