in lib/src/report/static_analysis.dart [19:71]
Future<ReportSection> staticAnalysis(PackageContext context) async {
final packageDir = context.packageDir;
final analysisResult = await _analyzePackage(context);
final errors = analysisResult.errors;
final warnings = analysisResult.warnings;
final lints = analysisResult.lints;
// Only try to run dartfmt if there where no errors.
final formattingIssues = errors.isEmpty
? await _formatPackage(
packageDir,
context.toolEnvironment,
usesFlutter: context.usesFlutter,
lineLength: context.options.lineLength,
)
: <Issue>[];
final status = (errors.isEmpty && warnings.isEmpty)
? (formattingIssues.isEmpty && lints.isEmpty
? ReportStatus.passed
: ReportStatus.partial)
: ReportStatus.failed;
// 10 points: static analysis has 0 errors
// 20 points: static analysis has 0 errors, warnings
// 30 points: static analysis has 0 errors, warnings, lints
var grantedPoints = 0;
if (errors.isEmpty) {
grantedPoints = 10;
if (warnings.isEmpty) {
grantedPoints = 20;
if (lints.isEmpty && formattingIssues.isEmpty) {
grantedPoints = 30;
}
}
}
return makeSection(
id: ReportSectionId.analysis,
title: 'Pass static analysis',
maxPoints: 30,
subsections: [
Subsection(
'code has no errors, warnings, lints, or formatting issues',
[...errors, ...warnings, ...lints, ...formattingIssues],
grantedPoints,
30,
status,
)
],
basePath: packageDir,
);
}