Find true high-risk zones in your code
I love the movie The Perfect Storm. The scene when a massive wave crashes onto a fishing boat always sticks with me. I suspect some of your files look a lot like that boat; at least, some of mine certainly have. These files usually have many rows, lot of ifs and lack of tests and can bring your production down at any time.
I remember one project in particular where we had a moderately complex computation function that was changed very often. It involved a mix of services and a shared, scoped(!!) Entity Framework context. Each class mutated the context's internal state, and those changes cascaded through multiple layers. The result was that customers reported seemingly random bugs that were nearly impossible to reproduce as it depended on the shape of the data at that moment. Every time we tried to fix one bug, two more would appear.
To identify these annoying parts of your code, you can use a combination of behavior and complexity analysis.
Combining cyclomatic complexity with change frequency reveals your codebase's true danger zones. Complex code isn't necessarily bad if it rarely changes.
Frequently changed code isn't a problem if it's simple.
But when you find files that are both complex AND frequently modified, you've found technical debt that actively damages your team's velocity and quality of sleep.
By plotting complexity against change frequency, you can visualize exactly which files deserve immediate refactoring attention versus which can safely be left alone.
Your codebase can be seen as a cosmic landscape plotted by complexity (vertical) and change frequency (horizontal):
Complex but rarely touched. Legacy code or stable algorithms that simply work. Monitor them, but they're not your immediate threat.
The event horizon. Complex AND constantly changing, sucking in developer time and generating bugs. These are the danger zones demanding immediate refactoring.
Simple and stable. Config files, constants, utilities. Vast, predictable, requiring little attention. Ideal code, if you ask me.
Frequently changing but simple. UI components, API endpoints, feature flags. Their simplicity makes frequent changes safe. Healthy, adaptive code.