Skip to content

Command Line Interface

v1.x vs v2.x

  • v1.x was written in pure python
  • v2.x was written in rust (with python and node.js bindings)

Version 2.x is intended to be backwards compatible, but a complete rewrite in rust prompted a major version bump.

The minimum versions (badges) specified here hyperlink to different repositories. Anything established in v2.x will correspond to the rust project. Anything established in v1.4.6 or later (before v2.0.0) will correspond to the pure python project. Anything established before v1.4.6 will correspond to pure python sources in the cpp-linter-action project.

Usage
cpp-linter [OPTIONS] [files]... [COMMAND]

Commands

version

Display the cpp-linter version and exit.

help

Print this message or the help of the given subcommand(s)

Arguments

files

An explicit path to a file. This can be specified zero or more times, resulting in a list of files. The list of files is appended to the internal list of 'not ignored' files. Further filtering can still be applied (see Source options).

General options

-v, --verbosity

1.3.0 Default"info"

This controls the action's verbosity in the workflow's logs. This option does not affect the verbosity of resulting thread comments or file annotations.

-V, --version

1.4.6 Default""

The desired version of the clang tools to use. Accepted options are strings which can be 8, 9, 10, 11, 12, 13, 14, 15, 16, 17.

  • Set this option to a blank string ('') to use the platform's default installed version.
  • This value can also be a path to where the clang tools are installed (if using a custom install location). All paths specified here are converted to absolute.

Source options

-e, --extensions

1.4.6 Default"c,h,C,H,cpp,hpp,cc,hh,c++,h++,cxx,hxx"

A comma-separated list of file extensions to analyze.

-r, --repo-root

1.4.6 Default"."

The relative path to the repository root directory. This path is relative to the runner's GITHUB_WORKSPACE environment variable (or the current working directory if not using a CI runner).

-i, --ignore

1.3.0 Default".github|target"

Set this option with path(s) to ignore (or not ignore).

  • In the case of multiple paths, you can use | to separate each path.
  • There is no need to use ./ for each entry; a blank string ('') represents the repo-root path.
  • This can also have files, but the file's path (relative to the --repo-root) has to be specified with the filename.
  • Submodules are automatically ignored. Hidden directories (beginning with a .) are also ignored automatically.
  • Prefix a path with ! to explicitly not ignore it. This can be applied to a submodule's path (if desired) but not hidden directories.
  • Glob patterns are supported here. Path separators in glob patterns should use / because \ represents an escaped literal.

-l, --lines-changed-only

1.5.0 contents: read Default"true"

This controls what part of the files are analyzed. The following values are accepted:

  • false: All lines in a file are analyzed.
  • true: Only lines in the diff that contain additions are analyzed.
  • diff: All lines in the diff are analyzed (including unchanged lines but not subtractions).

-f, --files-changed-only

1.3.0 contents: read Default"false"

Set this option to false to analyze any source files in the repo. This is automatically enabled if --lines-changed-only is enabled.

Note

The GITHUB_TOKEN should be supplied when running on a private repository with this option enabled, otherwise the runner does not not have the privilege to list the changed files for an event.

See Authenticating with the GITHUB_TOKEN.

Clang-format options

-s, --style

1.4.6 Default"llvm"

The style rules to use.

  • Set this to file to have clang-format use the closest relative .clang-format file.
  • Set this to a blank string ('') to disable using clang-format entirely.

Note

If this is not a blank string, then it is also passed to clang-tidy (if --tidy_checks is not -*). This is done to ensure suggestions from both clang-tidy and clang-format are consistent.

-M, --ignore-format

1.9.0

Similar to --ignore but applied exclusively to files analyzed by clang-format.

Clang-tidy options

-c, --tidy-checks

1.4.6 Default"boost-*,bugprone-*,performance-*,readability-*,portability-*,modernize-*,clang-analyzer-*,cppcoreguidelines-*"

A comma-separated list of globs with optional - prefix. Globs are processed in order of appearance in the list. Globs without - prefix add checks with matching names to the set, globs with the - prefix remove checks with matching names from the set of enabled checks. This option's value is appended to the value of the 'Checks' option in a .clang-tidy file (if any).

  • It is possible to disable clang-tidy entirely by setting this option to '-*'.
  • It is also possible to rely solely on a .clang-tidy config file by specifying this option as a blank string ('').

See also clang-tidy docs for more info.

-p, --database

1.4.0

The path that is used to read a compile command database. For example, it can be a CMake build directory in which a file named compile_commands.json exists (set CMAKE_EXPORT_COMPILE_COMMANDS to ON). When no build path is specified, a search for compile_commands.json will be attempted through all parent paths of the first input file. See LLVM docs about setup tooling for an example of setting up Clang Tooling on a source tree.

-x, --extra-arg

A string of extra arguments passed to clang-tidy for use as compiler arguments. This can be specified more than once for each additional argument. Recommend using quotes around the value and avoid using spaces between name and value (use = instead):

cpp-linter --extra-arg="-std=c++17" --extra-arg="-Wall"

-D, --ignore-tidy

1.9.0

Similar to --ignore but applied exclusively to files analyzed by clang-tidy.

Feedback options

-g, --thread-comments

1.6.1 contents: write Default"false"

Set this option to true to enable the use of thread comments as feedback. Set this to update to update an existing comment if one exists; the value 'true' will always delete an old comment and post a new one if necessary.

Note

To use thread comments, the GITHUB_TOKEN (provided by Github to each repository) must be declared as an environment variable.

See Authenticating with the GITHUB_TOKEN.

-t, --no-lgtm

1.6.1 Default"true"

Set this option to true or false to enable or disable the use of a thread comment that basically says 'Looks Good To Me' (when all checks pass).

Important

The --thread-comments option also notes further implications.

-w, --step-summary

1.6.0 Default"false"

Set this option to true or false to enable or disable the use of a workflow step summary when the run has concluded.

-a, --file-annotations

1.4.3 Default"true"

Set this option to false to disable the use of file annotations as feedback.

-d, --tidy-review

1.7.0 pull-requests: write experimental Default"false"

Set to true to enable Pull Request reviews from clang-tidy.

-m, --format-review

1.7.0 pull-requests: write Default"false"

Set to true to enable Pull Request reviews from clang-format.

-R, --passive-reviews

1.10.0 pull-requests: write Default"false"

Set to true to prevent Pull Request reviews from approving or requesting changes.