devops.cpp.style_rules

C++ rules for mstd devops.

Functions

check_header_guards(file_rule_input)

Check if the C++ header file has proper header guards.

find_define_macro(lines, macro)

Check if the #define for the given macro exists in the lines.

find_header_guard(lines)

Find the header guard macro in the given lines.

Classes

CheckHeaderGuards()

Rule to check for proper header guards in C++ header files.

CheckKeySeqOrder(key_sequence)

Rule to check that a specific key sequence appears only in a given order.

Exceptions

HeaderGuardError

Custom exception for header guard errors.

class devops.cpp.style_rules.CheckKeySeqOrder(key_sequence)[source]

Bases: Rule

Rule 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: Exception

Custom 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.

Parameters:
  • lines (list[str]) – The lines of the header file.

  • macro (str) – The header guard macro to look for.

Returns:

bool – True if the #define for the macro is found, False otherwise.

Return type:

bool

devops.cpp.style_rules.find_header_guard(lines)[source]

Find the header guard macro in the given lines.

Parameters:

lines (list[str]) – The lines of the header file.

Returns:

str – The header guard macro if found.

Raises:

HeaderGuardError – If the header guard is not properly defined.

Return type:

str

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:

ResultType

class devops.cpp.style_rules.CheckHeaderGuards[source]

Bases: Rule

Rule to check for proper header guards in C++ header files.