devops.cpp.ast.checks.no_maybe_unused_param

Flag [[maybe_unused]] on function, method and lambda parameters.

An unused parameter should be left unnamed, or keep its name only as a comment (const Frame & /*frame*/), instead of carrying the attribute. [[maybe_unused]] on variables, functions and members is not affected.

Only the standard spelling (maybe_unused / __maybe_unused__) written directly in the source is reported; an attribute coming from a macro expansion is skipped.

To disable this check for a project set:

[cpp]
ast_check_disabled_ids = ["noMaybeUnusedParam"]

Classes

NoMaybeUnusedParam()

Flag parameters marked [[maybe_unused]].

class devops.cpp.ast.checks.no_maybe_unused_param.NoMaybeUnusedParam[source]

Bases: Check

Flag parameters marked [[maybe_unused]].

id: str = 'noMaybeUnusedParam'

unique id, used as the cppcheck-style [id] suffix

visit(cursor, filename)[source]

Flag the cursor if it is a parameter marked [[maybe_unused]].

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 parameter carrying [[maybe_unused]], otherwise an empty list.

Return type:

list[Diagnostic]