runAnalyzer method
Future<DiagnosticResult>
runAnalyzer(
- Analyzer analyzer,
- AnalyzerContext context, {
- Logger? progressLogger,
Public method or function.
Implementation
Future<DiagnosticResult> runAnalyzer(
Analyzer analyzer,
AnalyzerContext context, {
Logger? progressLogger,
}) async {
final log = progressLogger ?? logger;
log.info('Running analyzer: ${analyzer.name}');
final stopwatch = Stopwatch()..start();
try {
final result = await analyzer.analyze(context);
stopwatch.stop();
final timedResult = DiagnosticResult(
analyzerName: result.analyzerName,
status: result.status,
issues: result.issues,
duration: stopwatch.elapsed,
timestamp: result.timestamp,
projectName: result.projectName,
);
log.success(
'${analyzer.name}: ${timedResult.status.label} (${timedResult.issueCount} issues)',
);
return timedResult;
} catch (e) {
stopwatch.stop();
log.error('${analyzer.name} failed: $e');
return DiagnosticResult(
analyzerName: analyzer.name,
status: CheckStatus.failed,
issues: [
DiagnosticIssue(
severity: Severity.error,
code: 'ANALYZER_ERROR',
title: 'Analyzer execution failed',
description: e.toString(),
),
],
duration: stopwatch.elapsed,
timestamp: DateTime.now(),
);
}
}