Skip to main content

cpplint

Supported VersionLanguageWebsite
1.5.5C/C++https://github.com/cpplint/cpplint

cpplint is a static analysis tool to check C/C++ files for style issues.

Getting Started#

To start using cpplint, enable it in your repository settings.

For more details for cpplint, see the command-line help:

$ cpplint --help

Configuration#

Here is a configuration example via sider.yml:

linter:  cpplint:    target: "src"    extensions: "c,cc"    headers: "hpp,hxx"    filter: "-whitespace,+whitespace/braces,-legal/copyright"    linelength: 100    exclude: "test/*.c"

You can use the following options to fine-tune cpplint to your project.

NameTypeDefault
root_dirstring-
targetstring, string[].
extensionsstring-
headersstring-
filterstring-
linelengthstring-
excludestring-

target#

This option allows you to specify files or directories to analyze. If you specify some targets, configure as follows:

linter:  cpplint:    target:      - "src"      - "lib"

extensions#

This option allows you to specify a comma-separated list of file extensions to analyze. For example, c++,cpp,cc,hh.

headers#

This option allows you to specify a comma-separated list of header file extensions to analyze. For example, hpp,hxx. The values are automatically added to the extensions list.

filter#

This option allows you to specify a comma-separated list of rule-filters to apply. For example, the rule names look like whitespace/indent. In that case, the category is whitespace.

To turn off, specify - as prefix like -whitespace or -whitespace/indent. On the other hand, to turn on, specify + like +whitespace or +whitespace/indent.

The following is an example:

linter:  cpplint:    filters: "-whitespace,+whitespace/braces"

If you omit the option, all the rules will be applied.

linelength#

This option allows you to specify a line-length for the project.

exclude#

This option allows you to exclude files to analyze. You can specify some files as follows:

linter:  cpplint:    exclude:      - "src/*.cc"      - "test/*.cc"

Recommended Ruleset#

Sider provides our recommended ruleset for cpplint. If your repository does not include CPPLINT.cfg, the recommended ruleset will be used. For more details, please visit Recommended Ruleset.