When GitLab Duo runs static complexity analysis on your merge request, it measures cyclomatic complexity for every function you touched or added. This helps catch overly complex code before it gets merged.
There are two ways the analysis can run: tool-based, using radon directly on your source files for precise results, or LLM-approximated, where the AI reads your code and counts decision points manually, producing only an estimate.
If you saw an info box in the MR comment about improving accuracy, the sections below explain how to enable radon in your project.
If a Merge Request Was Linked
The analysis agent detected that your project can support radon but doesn't have it installed yet. It created a merge request that adds (or updates) your .gitlab/duo/agent-config.yml file to include pip install radon in the setup step.
The MR adds a configuration like this:
version: 1
base_image: python:3.12-slim
setup:
- pip install radon If your project already had an agent-config.yml, the MR modifies it to add radon to the existing setup steps.
If No Merge Request Was Linked
The analysis agent found an existing .gitlab/duo/agent-config.yml in your repository but could not safely modify it. This typically happens when:
- The
base_imageis not Python-compatible (e.g.,node:20,ruby:3.2,golang:1.22) - The setup steps use a package manager other than pip
- The config structure is unusual or the agent wasn't confident it could merge correctly
Python Base Image
If your base_image is any Python variant (python:*, debian:*, ubuntu:*), add to your setup:
setup:
- pip install radon # Add this line
- # ... your existing setup steps Node.js Base Image
If your base image is Node-based, you'll need Python available:
setup:
- apt-get update && apt-get install -y python3 python3-pip
- pip3 install radon
- # ... your existing setup steps Other Base Images
For Alpine, Ruby, Go, or other images, ensure Python 3 and pip are available, then pip install radon.
The Configuration File
The file .gitlab/duo/agent-config.yml configures the execution environment for GitLab Duo agent workflows. It specifies:
base_image— The Docker image used as the runtime environmentsetup— Shell commands that run before any agent workflow starts
When this file exists and includes radon, the complexity analysis agent can call radon cc directly on your source files for exact cyclomatic complexity scores. Without it, the agent falls back to LLM-based estimation, which is less precise.
What Is Cyclomatic Complexity?
Cyclomatic complexity (CC) measures the number of independent paths through a function. It counts decision points like if, for, while, case, catch, &&, ||, and ternary operators.
| CC Score | Rank | Risk Level |
|---|---|---|
| 1–5 | A | Simple, low risk |
| 6–10 | B | Moderate, well-structured |
| 11–15 | C | More complex, consider refactoring |
| 16–20 | D | Complex, should refactor |
| 21–25 | E | Very complex, high risk |
| 26+ | F | Untestable, must refactor |
Functions with CC above 10 are harder to test and more likely to contain bugs. The analysis highlights these so you can address them during code review.