clang_tools.clang_tidy
¶
Parse output from clang-tidy’s stdout
-
class cpp_linter.clang_tools.clang_tidy.TidyNotification(notification_line: tuple[str, int | str, int | str, str, str, str], database: list[dict[str, str]] | None =
None
)[source]¶ Create a object that decodes info from the clang-tidy output’s initial line that details a specific notification.
- Parameters:¶
- notification_line: tuple[str, int | str, int | str, str, str, str]¶
The first line in the notification parsed into a
tuple
ofstr
that represent the different components of the notification’s details.- database: list[dict[str, str]] | None =
None
¶ The compilation database deserialized from JSON, only if
--database
argument points to a valid path containing acompile_commands.json file
.
- diagnostic¶
The columns of the line that triggered the notification.
- rationale¶
The rationale of the notification.
- severity¶
The priority level of notification (warning/error).
- line¶
The line number of the source file.
- cols¶
The columns of the line that triggered the notification.
- filename¶
The source filename concerning the notification.
- class cpp_linter.clang_tools.clang_tidy.TidyAdvice(notes: list[TidyNotification])[source]¶
- diagnostics_in_range(start: int, end: int) str [source]¶
Get a markdown formatted list of fixed diagnostics found between a
start
andend
range of lines.
- get_suggestion_help(start: int, end: int) 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).
- cpp_linter.clang_tools.clang_tidy.tally_tidy_advice(files: list[FileObj]) int [source]¶
Returns the sum of clang-format errors
- cpp_linter.clang_tools.clang_tidy.run_clang_tidy(command: str, file_obj: FileObj, checks: str, lines_changed_only: int, database: str, extra_args: list[str], db_json: list[dict[str, str]] | None, tidy_review: bool, style: str) TidyAdvice [source]¶
Run clang-tidy on a certain file.
- Parameters:¶
- command: str¶
The clang-tidy command to use (usually a resolved path).
- file_obj: FileObj¶
Information about the
FileObj
.- checks: str¶
The
str
of comma-separated regulate expressions that describe the desired clang-tidy checks to be enabled/configured.- lines_changed_only: int¶
A flag that forces focus on only changes in the event’s diff info.
- database: str¶
The path to the compilation database.
- extra_args: list[str]¶
A list of extra arguments used by clang-tidy as compiler arguments.
Note
If the list is only 1 item long and there is a space in the first item, then the list is reformed from splitting the first item by whitespace characters.
cpp-linter --extra-arg="-std=c++14 -Wall"
is equivalent to
cpp-linter --extra-arg=-std=c++14 --extra-arg=-Wall
- db_json: list[dict[str, str]] | None¶
The compilation database deserialized from JSON, only if
database
parameter points to a valid path containing acompile_commands.json file
.- tidy_review: bool¶
A flag to enable/disable creating a diff suggestion for PR review comments.