devops.cpp

Package defining C++ check rules.

devops.cpp.add_license_header(file, header_to_add, *, dry_run=False)[source]

Add the license header to the file content if it’s missing.

Parameters:
  • file (str | Path) – The path to the file to modify.

  • header_to_add (str | Path) – The path to the file containing the license header to add.

  • dry_run (bool) – If True, do not modify the file, only simulate the addition.

Returns:

bool – True if the license header was added, False if it was already present.

Raises:

DevOpsFileNotFoundError – If the header file does not exist.

Return type:

bool

devops.cpp.build_cpp_rules(config=CppConfig(style_checks=True, license_header_check=True, license_header=None, check_only_staged_files=False, header_guards_according_to_filepath=False))[source]

Build and return the list of C++ rules based on the global configuration.

Parameters:

config (CppConfig) – The global C++ configuration.

Returns:

list[Rule] – The list of C++ rules.

Return type:

list[Rule]

devops.cpp.filter_buggy_cpp(files)[source]

Filter out known buggy C++ header files from a list of files.

Parameters:

files (list[str]) – The list of file paths to filter.

Returns:

list[str] – The filtered list of file paths excluding known buggy C++ headers.

Return type:

list[str]

devops.cpp.run_cpp_checks(rules, config=CppConfig(style_checks=True, license_header_check=True, license_header=None, check_only_staged_files=False, header_guards_according_to_filepath=False), dirs=None)[source]

Run C++ checks based on the provided rules.

Returns immediately after encountering the first file with errors.

Parameters:
  • rules (list[Rule]) – The list of rules to apply.

  • config (CppConfig) – The global C++ configuration.

  • dirs (list[Path] | None)

Raises:

CppCheckError – If invalid (non-file or non-line) rules are provided.

Returns:

bool – True if all checks pass, False if any check fails.

Return type:

bool

Modules

buggy_cpp_files

Module for filtering known buggy C++ header files.

build_rules

Module to build C++ rules based on global configuration.

checks

C++ checks module.

license_header

Module to check for license headers in C++ files.

style_rules

C++ rules for mstd devops.