averageCYCLO function

double averageCYCLO(
  1. Iterable<LintFileReport> records
)

Implementation

double averageCYCLO(Iterable<LintFileReport> records) {
  final totalSloc = totalSLOC(records);

  return totalSloc > 0
      ? records.fold<num>(
            0,
            (prevValue, fileReport) =>
                prevValue +
                fileReport.functions.values.fold(
                  0,
                  (prevValue, functionReport) =>
                      prevValue +
                      (functionReport
                              .metric(CyclomaticComplexityMetric.metricId)
                              ?.value ??
                          0),
                ),
          ) /
          totalSloc
      : 0;
}