# Code Quality Metrics

## Functional quality metrics

### Unit test metrics

High coverage and low dependencies show that the code is testable and therefore well isolated and easy to maintain. Low complexity also makes code readable and maintainable and helps enforce single responsibility. Real unit tests run very fast as they don't call external components.

| Code Quality Metrics | New and Project Code  |
| -------------------- | --------------------- |
| Unit test coverage   | >= 80% block coverage |
| Unit test speed      | <= 10 seconds         |
| Dependencies/method  | <= 10                 |
| Complexity/method    | <= 7                  |

### Component

Functional testing typically covers pair combinations of the system states.

### Integration

Functional tests have one test per message and error. Messages and errors that are handled the same way use the same test.

### Contract

Limited to what the consuming teams need that isn't covered by existing unit, component, and integration tests. Often added to over time.

### End to End

End to end tests cover acceptance tests from scenarios.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mojaloop.gitbook.io/mojaloop/legacy/contributors-guide/tools-and-technologies/code-quality-metrics.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
