devops.cpp.style_rules
C++ rules for mstd devops.
Functions
|
Check if the C++ header file has proper header guards. |
|
Find the header guard macro and collect all structural guard errors. |
|
Compute the expected header guard macro name for a file path. |
|
Check if the #define for the given macro exists in the lines. |
|
Find the header guard macro in the given lines. |
Classes
Rule to check for proper header guards in C++ header files. |
|
|
Rule to check that a specific key sequence appears only in a given order. |
Exceptions
Custom exception for header guard errors. |
- class devops.cpp.style_rules.CheckKeySeqOrder(key_sequence)[source]
Bases:
RuleRule to check that a specific key sequence appears only in a given order.
- Parameters:
key_sequence (str)
- exception devops.cpp.style_rules.HeaderGuardError[source]
Bases:
ExceptionCustom exception for header guard errors.
- devops.cpp.style_rules.find_define_macro(lines, macro)[source]
Check if the #define for the given macro exists in the lines.
- devops.cpp.style_rules.collect_header_guard_errors(lines)[source]
Find the header guard macro and collect all structural guard errors.
Unlike raising on the first problem found, this gathers every applicable structural issue (missing
#define, a#definethat doesn’t immediately follow#ifndef, a missing#endif) so callers can report them all together instead of one at a time across repeated runs.- Parameters:
- Returns:
tuple[str | None, list[str]] – The header guard macro if an
#ifndefwas found (else None), and the list of error messages describing every structural problem found. An empty list means the header guard is well-formed.- Return type:
- devops.cpp.style_rules.find_header_guard(lines)[source]
Find the header guard macro in the given lines.
- Parameters:
- Returns:
str – The header guard macro if found.
- Raises:
HeaderGuardError – If the header guard is not properly defined. If more than one structural problem is present, all of them are reported together in a single error message.
- Return type:
- devops.cpp.style_rules.expected_header_guard_macro(path, pattern)[source]
Compute the expected header guard macro name for a file path.
- Parameters:
path (Path) – The file path to derive the macro name from.
pattern (str or None) – A format string with
{path}and{ext}placeholders used to build the macro name, or None to use the default__{path}_{ext}__pattern.{path}is built from the path with any leadinginclude/,test/orsrc/directory removed and its extension stripped: each remaining directory and the file stem is converted from camelCase/PascalCase to SNAKE_CASE (sovelocityVerletbecomesVELOCITY_VERLET, notVELOCITYVERLET), then joined with__.{ext}is the upper-cased extension (HPP,IMPL_HPP,TPPorH).
- Returns:
str – The expected header guard macro name.
- Return type:
- devops.cpp.style_rules.check_header_guards(file_rule_input)[source]
Check if the C++ header file has proper header guards.
- Parameters:
file_rule_input (FileRuleInput) – The input containing the file content and path to check.
- Returns:
ResultType – The result of the header guard check.
- Return type: