devops.cpp.ast.checks.no_const_value_param
Flag top-level const on parameters passed by value.
A by-value parameter is a local copy, so marking it const adds nothing to
the function’s interface and only adds noise: void f(const int x) should
be void f(int x). The same holds for a const pointer itself
(int *const p). Pointers to const (const int *p) and references
(const T &, T &&) are not affected.
clang-tidy’s readability-avoid-const-params-in-decls only covers
declarations; this check also covers definitions and lambdas. Only a const
written in the parameter itself is flagged: const coming from a type alias
or a macro, unnamed parameters, parameters of deleted or defaulted functions
and parameters inside function types (e.g. function pointers) are ignored.
To disable this check for a project set:
[cpp]
ast_check_disabled_ids = ["noConstValueParam"]
Classes
Flag a by-value parameter declared with top-level |
- class devops.cpp.ast.checks.no_const_value_param.NoConstValueParam[source]
Bases:
CheckFlag a by-value parameter declared with top-level
const.- visit(cursor, filename)[source]
Flag the cursor if it is a
constby-value parameter.- Parameters:
cursor (clang.Cursor) – The AST node currently being visited.
filename (str) – Path of the file being checked.
- Returns:
list[Diagnostic] – A single diagnostic if cursor is a named function, method or lambda parameter whose own type is
constand not a reference, otherwise an empty list.- Return type: