devops.cpp.ast.checks.enforce_member_function_leading_underscore
Enforce a leading underscore on private and protected member functions.
Any ordinary member function (including static and template member
functions) declared under a private: or protected: access specifier
must have a name starting with _ (e.g. _compute, _isReady).
Public member functions are never flagged, since they are part of the
class’s external interface and not the concern of this check.
A handful of member-function kinds are never flagged, because their name is fixed by the language or by a base class and renaming them isn’t something the author can freely do:
Constructors and destructors — their name is always the class’s own name (or
~ClassName).Operator overloads and conversion functions (
operator==,operator[],operator int() const, …) — the operator’s spelling is fixed by the language grammar.Methods that override a base class’s virtual method — the override must keep the base method’s exact name to bind at all.
As with memberLeadingUnderscore, a member function synthesized by a macro invoked on the same source line is not flagged either.
To disable this check for a project set:
[cpp]
ast_check_disabled_ids = ["memberFunctionLeadingUnderscore"]
Classes
Flag private/protected member functions without a leading underscore. |
- class devops.cpp.ast.checks.enforce_member_function_leading_underscore.EnforceMemberFunctionLeadingUnderscore[source]
Bases:
CheckFlag private/protected member functions without a leading underscore.
Reporting is deferred to finalize() for the same reason as in EnforceMemberLeadingUnderscore: whether a candidate was synthesized by a macro can only be known once every
MACRO_INSTANTIATIONcursor in the file has been seen.- visit(cursor, filename)[source]
Record macro-instantiation lines and candidate methods for filename.
- Parameters:
cursor (clang.Cursor) – The AST node currently being visited.
filename (str) – Path of the file being checked.
- Returns:
list[Diagnostic] – Always empty — diagnostics are emitted from finalize() once the whole file (including its macro instantiations) is known.
- Return type: