devops.cpp.ast.checks.no_final_keyword

Flag use of the final specifier on classes, structs, and methods.

final prevents a class from being derived from, or a virtual method from being overridden further down the hierarchy. Banning it keeps the class hierarchy open for extension (e.g. test doubles, future subclasses) instead of locking it down at the point of declaration.

To disable this check for a project set:

[cpp]
ast_check_disabled_ids = ["noFinalKeyword"]

Classes

NoFinalKeyword()

Flag final on a class/struct declaration or a virtual method.

class devops.cpp.ast.checks.no_final_keyword.NoFinalKeyword[source]

Bases: Check

Flag final on a class/struct declaration or a virtual method.

id: str = 'noFinalKeyword'

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

visit(cursor, filename)[source]

Flag the cursor if it declares something marked final.

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 the cursor is a disallowed final class/struct/method declaration, otherwise an empty list.

Return type:

list[Diagnostic]