Provides SARIF (Static Analysis Results Interchange Format) reporting functionality.
Contains information about the tool used for analysis in SARIF reports.
Name of the tool.
Version of the tool.
Converts the tool information to a JSON string.
Returns:- A JSON representation of the tool's name and version.
nothrow string
intToString(int
value);
Converts an integer to a string.
Parameters:intvalue | The integer value to convert. |
Returns:A string representation of the integer.
Represents a SARIF result containing a rule ID, message, and location.
Rule identifier.
Error or warning message.
URI of the affected file.
Line number where the issue occurs.
Column number where the issue occurs.
Converts the SARIF result to a JSON string.
Returns:- A JSON string representing the SARIF result, including the rule ID, message, and location.
nothrow void
addSarifDiagnostic(const SourceLoc
loc, const(char)*
format, va_list
ap, ErrorKind
kind);
Adds a SARIF diagnostic entry to the diagnostics list.
Formats a diagnostic message and appends it to the global diagnostics array, allowing errors, warnings, or other diagnostics to be captured in SARIF format.
Parameters:SourceLocloc | The location in the source code where the diagnostic was generated (includes file, line, and column). |
const(char)*format | The printf-style format string for the diagnostic message. |
va_listap | The variadic argument list containing values to format into the diagnostic message. |
ErrorKindkind | The type of diagnostic, indicating whether it is an error, warning, deprecation, etc. |
Represents a SARIF report containing tool information, invocation, and results.
Information about the analysis tool.
Execution information.
List of SARIF results (errors, warnings, etc.).
Converts the SARIF report to a JSON string.
Returns:- A JSON string representing the SARIF report, including the tool information, invocation, and results.
Represents invocation information for the analysis process.
Whether the execution was successful.
Converts the invocation information to a JSON string.
Returns:- A JSON representation of the invocation status.
nothrow string
formatErrorMessage(const(char)*
format, va_list
ap);
Formats an error message using a format string and a variable argument list.
Parameters:const(char)*format | The format string to use. |
va_listap | A variable argument list for the format string. |
Returns:A formatted error message string.
nothrow string
errorKindToString(ErrorKind
kind);
Converts anErrorKind value to a SARIF-compatible string representation for the severity level.
Parameters:ErrorKindkind | TheErrorKind value to convert (e.g., error, warning, deprecation). |
Returns:A SARIF-compatible string representing theErrorKind level, such as "error" or "warning".
nothrow void
generateSarifReport(bool
executionSuccessful);
Generates a SARIF (Static Analysis Results Interchange Format) report and prints it tostdout.
This function constructs a JSON-formatted SARIF report that includes information about the tool used (such as compiler version and URI), the invocation status (indicating whether the execution was successful), and a detailed array of diagnostics (results) whenexecutionSuccessful is set tofalse. Each diagnostic entry in the results array contains the rule identifier (ruleId), a text message describing the issue (message), the severity level (level), and the location of the issue in the source code, including the file path, line number, and column number. The SARIF report adheres to the SARIF 2.1.0 standard.
Parameters:boolexecutionSuccessful | true for an emptyresults array;false for detailed errors. |
Throws:This function is marked asnothrow and does not throw exceptions.