clang_tools.clang_format
¶
Parse output from clang-format’s XML suggestions.
- class cpp_linter.clang_tools.clang_format.FormatReplacement(cols: int, null_len: int, text: str)[source]¶
An object representing a single replacement.
- Parameters:¶
- cols¶
The columns number of where the suggestion starts on the line
- null_len¶
The number of bytes removed by suggestion
- class cpp_linter.clang_tools.clang_format.FormatReplacementLine(line_numb: int)[source]¶
An object that represents a replacement(s) for a single line.
- line¶
The line number of where the suggestion starts
- replacements : List[FormatReplacement]¶
A list of
FormatReplacement
object(s) representing suggestions.
- class cpp_linter.clang_tools.clang_format.FormatAdvice(filename: str)[source]¶
A single object to represent each suggestion.
- Parameters:¶
- filename¶
The source file that the suggestion concerns.
- replaced_lines : List[FormatReplacementLine]¶
A list of
FormatReplacementLine
representing replacement(s) on a single line.
- cpp_linter.clang_tools.clang_format.tally_format_advice(files: list[FileObj]) int [source]¶
Returns the sum of clang-format errors
- cpp_linter.clang_tools.clang_format.parse_format_replacements_xml(xml_out: str, file_obj: FileObj, lines_changed_only: int) FormatAdvice [source]¶
Parse XML output of replacements from clang-format.
- cpp_linter.clang_tools.clang_format.run_clang_format(command: str, file_obj: FileObj, style: str, lines_changed_only: int, format_review: bool) FormatAdvice [source]¶
Run clang-format on a certain file
- Parameters:¶
- command: str¶
The clang-format command to use (usually a resolved path).
- file_obj: FileObj¶
Information about the
FileObj
.- style: str¶
The clang-format style rules to adhere. Set this to ‘file’ to use the relative-most .clang-format configuration file.
- lines_changed_only: int¶
A flag that forces focus on only changes in the event’s diff info.
- format_review: bool¶
A flag to enable/disable creating a diff suggestion for PR review comments.