MaintainabilityResult class
Result of maintainability calculation for a single function.
Contains the Maintainability Index (MI) and all contributing metrics. Use rating to quickly categorize the result:
good(MI >= 80): Easy to maintainmoderate(50 <= MI < 80): Acceptablepoor(MI < 50): Needs refactoring
Example:
final calculator = MaintainabilityIndexCalculator();
final result = calculator.calculate(functionBody);
print('MI: ${result.maintainabilityIndex}');
if (result.rating == MaintainabilityRating.poor) {
print('Consider refactoring this function');
}
Constructors
- MaintainabilityResult({required double maintainabilityIndex, required int cyclomaticComplexity, required int cognitiveComplexity, required HalsteadMetrics halsteadMetrics, required int linesOfCode, required MaintainabilityRating rating})
-
const
Properties
- cognitiveComplexity → int
-
SonarQube cognitive complexity (how hard code is to understand).
final
- cyclomaticComplexity → int
-
McCabe's cyclomatic complexity (number of linearly independent paths).
final
- halsteadMetrics → HalsteadMetrics
-
Halstead software science metrics.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- linesOfCode → int
-
Total lines of code in the function body.
final
- maintainabilityIndex → double
-
The Maintainability Index (0-100, higher is better).
final
- rating → MaintainabilityRating
-
Rating category based on MI thresholds.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited