call method

Future<Iterable<Indicate>> call({
  1. required Directory dir,
  2. required String base,
  3. required String head,
})

Implementation

Future<Iterable<Indicate>> call({
  required Directory dir,
  required String base,
  required String head,
}) async {
  final result = await _dartRepository.analyze(dir: dir);

  final indicates = await Future.wait(result.diagnostics.map((diag) async {
    // If severity is none, then it is excluded from the list.
    if (diag.severity == DiagnosticSeverity.none) return null;

    final body = diag.body;
    final path = p.relative(diag.location.file);
    final line = diag.location.range.start.line;

    final commitId = await _gitRepository.getLatestCommitId(
      base: base,
      head: head,
      path: path,
      line: line,
    );

    // If there are no commits between {base} and {head}, then the commit id is empty.
    // In this case, it is excluded from the list.
    if (commitId.isEmpty) return null;

    return Indicate(
      diagHash: diag.sha,
      body: body,
      commitId: commitId,
      path: path,
      line: line,
    );
  }));

  return indicates.whereType<Indicate>();
}