jsonReport function

String jsonReport(
  1. CheckResult result
)

Machine-readable report, "format": "tarpit-json", "formatVersion": 1.

Implementation

String jsonReport(CheckResult result) {
  final data = {
    'format': 'tarpit-json',
    'formatVersion': 1,
    'tool': {'name': 'tarpit', 'version': packageVersion},
    'files': result.files,
    'untypedFiles': result.untyped,
    'summary': {
      'error': result.count(Severity.error),
      'warning': result.count(Severity.warning),
      'info': result.count(Severity.info),
    },
    'findings': [for (final f in result.findings) f.toJson()],
  };
  return '${const JsonEncoder.withIndent('  ').convert(data)}\n';
}