getViolations method

List<FunctionMetrics> getViolations()

Returns functions that violate thresholds (hotspots).

Implementation

List<FunctionMetrics> getViolations() {
  return _functionMetrics.values.where((func) {
    return func.result.maintainabilityIndex < thresholds.minMaintainability ||
        func.result.cyclomaticComplexity > thresholds.maxCyclomatic ||
        func.result.cognitiveComplexity > thresholds.maxCognitive ||
        func.result.linesOfCode > thresholds.maxLinesOfCode;
  }).toList()
    ..sort((a, b) => a.result.maintainabilityIndex
        .compareTo(b.result.maintainabilityIndex));
}