devops.cpp.ast.checks.enforce_system_header_libs

Flag #include “lib/…” for libraries that must be included as system headers.

Some libraries are always meant to be included with angle brackets (e.g. #include <mstd/foo.hpp>), never with quotes (#include "mstd/foo.hpp"). This check flags any #include whose path’s first directory component matches one of the configured library names but uses quotes instead of angle brackets.

To disable this check for a project set:

[cpp]
ast_check_disabled_ids = ["enforceSystemHeaderLibs"]

Configure which libraries must be included as system headers via the per-check table; an empty/unset list disables the check entirely:

[cpp.ast_check_config.enforceSystemHeaderLibs]
libs = ["mstd"]

Classes

EnforceSystemHeaderLibs()

Flag quoted #includes of configured libraries that must use <...>.

class devops.cpp.ast.checks.enforce_system_header_libs.EnforceSystemHeaderLibs[source]

Bases: Check

Flag quoted #includes of configured libraries that must use <…>.

id: str = 'enforceSystemHeaderLibs'

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

configure(config)[source]

Load the set of library names that must be included as system headers.

Parameters:

config (dict) – Expected shape: {"libs": ["mstd"]}. When absent or empty, this check never flags anything.

Raises:

ConfigError – If libs is present but is not a list of strings.

Return type:

None

visit(cursor, filename)[source]

Flag the cursor if it’s a quoted #include of a configured library.

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 an #include directive that pulls in a configured library via quotes instead of angle brackets, otherwise an empty list.

Return type:

list[Diagnostic]