analyze method
Future<AnalyzedResult>
analyze(
- AnalyzerConfig config,
- ResolvedUnitResult resolvedUnitResult, {
- required String? filePath,
Implementation
Future<AnalyzedResult> analyze(
AnalyzerConfig config,
ResolvedUnitResult resolvedUnitResult, {
required String? filePath,
}) async {
if (filePath == null ||
!resolvedUnitResult.path.endsWith('.dart') ||
_isExcluded(resolvedUnitResult.path, config.excludePatterns)) {
// TODO: log?
return AnalyzedResult(filePath: '', issues: []);
}
final suppression = Suppression(
resolvedUnitResult.content,
resolvedUnitResult.lineInfo,
);
final internalResolvedUnitResult = InternalResolvedUnitResult(
path: resolvedUnitResult.path,
content: resolvedUnitResult.content,
unit: resolvedUnitResult.unit,
lineInfo: resolvedUnitResult.lineInfo,
);
final issues = config.rules
.where((rule) => !suppression.isSuppressed(rule.ruleId))
.expand((rule) => rule
.check(internalResolvedUnitResult)
.where((issue) => !suppression.isSuppressedAt(
rule.ruleId,
issue.location.start.line,
)))
.toList();
return AnalyzedResult(
filePath: filePath,
issues: issues,
);
}