Maintainability
Maintainability is an estimate of technical debt in the repo based on a standardized 10-point assessment of Duplication, Cyclomatic Complexity, Cognitive Complexity, and structural issues.
For every technical debt issue we identify during our 10-point inspection, we estimate a rough time it would take to resolve the problem. We refer to this as remediation time. It’s never perfect, but when viewed as an aggregate we find it’s a useful way to compare technical debt projects.
For files, we assign a letter rating from A to F based on the total remediation time of all of the technical debt issues that are identified. If an issue is classified as “Wontfix” or “Invalid” using our issue statuses, it will not count against the rating.
For repository-level metrics, it’s a bit more sophisticated. Over the years, we’ve found that our old GPAs tend to correlate very strongly with the size of a repository. In other words, large projects almost always score worse than small projects, reducing the value of the metric.
To make the repository-level maintainability rating more relevant, we compute a technical debt ratio, which is the total estimated remediation time divided by a very high level total estimated implementation time, based on repository size. Lower technical debt ratios are better.
Checks
The 10 checks outlined below are enabled by default in Code Climate. These checks will run on any file written in one of our Supported Languages for Maintainability.
Advanced Configuration
The maintainability checks listed below each ship with a default threshold. These thresholds can be adjusted using a
.codeclimate.yml
or.codeclimate.json
, as shown in our docs on Default Checks.
-
Argument count (
argument-count
) - Methods or functions defined with a high number of arguments -
Complex logic (
complex-logic
) - Boolean logic that may be hard to understand -
File length (
file-lines
) - Excessive lines of code within a single file -
Identical blocks of code (
identical-code
) - Duplicate code which is syntactically identical (but may be formatted differently) -
Method complexity (
method-complexity
) - Functions or methods that may be hard to understand (Cognitive Complexity) -
Method count (
method-count
)- Classes defined with a high number of functions or methods -
Method length(
method-lines
) - Excessive lines of code within a single function or method -
Nested control flow (
nested-control-flow
) - Deeply nested control structures like if or case -
Return statements (
return-statements
) - Functions or methods with a high number of return statements -
Similar blocks of code (
similar-code
) - Duplicate code which is not identical but shares the same structure (e.g. variable names may differ)
Related Issues
Duplication
Cyclomatic Complexity
Cognitive Complexity
How are maintainability ratings calculated?
Default maintainability thresholds
Updated almost 2 years ago