clang_tools.patcher
¶
A module to contain the abstractions about creating suggestions from a diff generated by the clang tool’s output.
- class cpp_linter.clang_tools.patcher.Suggestion(file_name: str)[source]¶
A data structure to contain information about a single suggestion.
- Parameters:¶
- class cpp_linter.clang_tools.patcher.ReviewComments[source]¶
A data structure to contain PR review comments from a specific clang tool.
- suggestions : List[Suggestion]¶
The list of actual comments
- tool_total : Dict[str, int | None]¶
The total number of concerns about a specific clang tool.
This may not equate to the length of
suggestions
because 1. There is no guarantee that all suggestions will fit within the PR’s diff. 2. Suggestions are a combined result of advice from both tools.A
None
value means a review was not requested from the corresponding tool.
- full_patch : Dict[str, str]¶
The full patch of all the suggestions (including those that will not fit within the diff)
- merge_similar_suggestion(suggestion: Suggestion) bool [source]¶
Merge a given
suggestion
into a similarSuggestion
- serialize_to_github_payload(tidy_version: str | None, format_version: str | None) tuple[str, list[dict[str, Any]]] [source]¶
Serialize this object into a summary and list of comments compatible with Github’s REST API.
- Parameters:¶
- Returns:¶
The returned tuple contains a brief summary (at index
0
) that contains markdown text describing the summary of the review comments.The list of
suggestions
(at index1
) is the serialized JSON object.
- class cpp_linter.clang_tools.patcher.PatchMixin[source]¶
An abstract mixin that unified parsing of the suggestions into PR review comments.
- get_suggestion_help(start, end) str [source]¶
Create helpful text about what the suggestion aims to fix.
The parameters
start
andend
are the line numbers (relative to file’s original content) encapsulating the suggestion.
- get_tool_name() str [source]¶
A function that must be implemented by derivatives to get the clang tool’s name that generated the
patched
data.
- get_suggestions_from_patch(file_obj: FileObj, summary_only: bool, review_comments: ReviewComments)[source]¶
Create a list of suggestions from the tool’s
patched
output.Results are stored in the
review_comments
parameter (passed by reference).