sarifReportToJsonString function
Encodes diagnostics as a pretty-printed SARIF 2.1.0 JSON string.
Mirrors scanDiagnosticsToJsonString's encoding convention (2-space
indent) so both output formats look consistent to a human reading
--output files side by side.
Implementation
String sarifReportToJsonString(
List<Map<String, dynamic>> diagnostics, {
required String rootPath,
required String toolVersion,
}) {
return const JsonEncoder.withIndent(' ').convert(
buildSarifReport(diagnostics, rootPath: rootPath, toolVersion: toolVersion),
);
}