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
Flag |
- class devops.cpp.ast.checks.no_final_keyword.NoFinalKeyword[source]
Bases:
CheckFlag
finalon a class/struct declaration or a virtual method.- 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
finalclass/struct/method declaration, otherwise an empty list.- Return type: