buildSarifReport function
Builds a full SARIF 2.1.0 log for diagnostics (enriched diagnostic
maps as produced by scanDiagnosticsToJson + audit's tier/category
enrichment). rootPath anchors the relative artifactLocation.uri
values. toolVersion should be saropaLintsVersion from
package:saropa_lints/saropa_lints.dart — passed in rather than read
here so this module has no dependency on the package's own export graph.
Implementation
Map<String, dynamic> buildSarifReport(
List<Map<String, dynamic>> diagnostics, {
required String rootPath,
required String toolVersion,
}) {
return <String, dynamic>{
r'$schema': _kSarifSchemaUri,
'version': _kSarifVersion,
'runs': [
<String, dynamic>{
'tool': <String, dynamic>{
'driver': <String, dynamic>{
'name': 'saropa_lints',
'version': toolVersion,
'rules': _ruleDescriptors(diagnostics),
},
},
'results': [
for (final diagnostic in diagnostics)
_resultFromDiagnostic(diagnostic, rootPath),
],
},
],
};
}