report function

void report(
  1. CustomLintResolver resolver,
  2. DiagnosticReporter reporter,
  3. AstNode node,
  4. LintCode code, {
  5. String? fingerprint,
})

Opt-in replacement for reporter.atNode. Reports the diagnostic as usual; if fingerprint is supplied, records it under the key the reporter will reconstruct from the same location.

Implementation

void report(
  CustomLintResolver resolver,
  DiagnosticReporter reporter,
  AstNode node,
  LintCode code, {
  String? fingerprint,
}) {
  reporter.atNode(node, code);
  if (fingerprint == null) return;

  final location = resolver.lineInfo.getLocation(node.offset);
  recordOverride(
    // When the env var pins the path, rootPath is ignored downstream — skip the fs walk.
    rootPath: _overridesPathIsPinned() ? '' : _projectRootFor(resolver.path),
    ruleId: code.name,
    filePath: resolver.path,
    line: location.lineNumber,
    column: location.columnNumber,
    fingerprint: fingerprint,
  );
}