Movatterモバイル変換


[0]ホーム

URL:


D Logo
Menu
Search

Library Reference

version 2.112.0

overview

Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.Requires a signed-in GitHub account. This works well for small changes.If you'd like to make larger changes you may want to consider usinga local clone.

dmd.sarif

Provides SARIF (Static Analysis Results Interchange Format) reporting functionality.
Authors:
Walter Bright
License:
Boost License 1.0

Sourcesarif.d

CoverageCode Coverage

Description

  • This module generates SARIF reports for DMD errors, warnings, and messages.
  • It supports JSON serialization of SARIF tools, results, and invocations.
  • The generated reports are compatible with SARIF 2.1.0 schema.

structToolInformation;
Contains information about the tool used for analysis in SARIF reports.
stringname;
Name of the tool.
stringtoolVersion;
Version of the tool.
nothrow stringtoJson();
Converts the tool information to a JSON string.
Returns:
  • A JSON representation of the tool's name and version.
nothrow stringintToString(intvalue);
Converts an integer to a string.
Parameters:
intvalueThe integer value to convert.
Returns:
A string representation of the integer.
structSarifResult;
Represents a SARIF result containing a rule ID, message, and location.
stringruleId;
Rule identifier.
stringmessage;
Error or warning message.
stringuri;
URI of the affected file.
intstartLine;
Line number where the issue occurs.
intstartColumn;
Column number where the issue occurs.
nothrow stringtoJson();
Converts the SARIF result to a JSON string.
Returns:
  • A JSON string representing the SARIF result, including the rule ID, message, and location.
nothrow voidaddSarifDiagnostic(const SourceLocloc, const(char)*format, va_listap, ErrorKindkind);
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:
SourceLoclocThe location in the source code where the diagnostic was generated (includes file, line, and column).
const(char)*formatThe printf-style format string for the diagnostic message.
va_listapThe variadic argument list containing values to format into the diagnostic message.
ErrorKindkindThe type of diagnostic, indicating whether it is an error, warning, deprecation, etc.
structSarifReport;
Represents a SARIF report containing tool information, invocation, and results.
ToolInformationtool;
Information about the analysis tool.
Invocationinvocation;
Execution information.
SarifResult[]results;
List of SARIF results (errors, warnings, etc.).
nothrow stringtoJson();
Converts the SARIF report to a JSON string.
Returns:
  • A JSON string representing the SARIF report, including the tool information, invocation, and results.
structInvocation;
Represents invocation information for the analysis process.
boolexecutionSuccessful;
Whether the execution was successful.
nothrow stringtoJson();
Converts the invocation information to a JSON string.
Returns:
  • A JSON representation of the invocation status.
nothrow stringformatErrorMessage(const(char)*format, va_listap);
Formats an error message using a format string and a variable argument list.
Parameters:
const(char)*formatThe format string to use.
va_listapA variable argument list for the format string.
Returns:
A formatted error message string.
nothrow stringerrorKindToString(ErrorKindkind);
Converts anErrorKind value to a SARIF-compatible string representation for the severity level.
Parameters:
ErrorKindkindTheErrorKind value to convert (e.g., error, warning, deprecation).
Returns:
A SARIF-compatible string representing theErrorKind level, such as "error" or "warning".
nothrow voidgenerateSarifReport(boolexecutionSuccessful);
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:
boolexecutionSuccessfultrue for an emptyresults array;false for detailed errors.
Throws:
This function is marked asnothrow and does not throw exceptions.
See Also:
Copyright © 1999-2026 by theD Language Foundation | Page generated byDdoc on Fri Feb 20 12:29:12 2026

[8]ページ先頭

©2009-2026 Movatter.jp