I found 231 lines in an old codebase that crash the moment they run

In November I spent a month getting an old codebase ready for an upgrade: 23,000 commits, 15 authors, a framework three major versions out of date. Step one was obvious. Run a static analysis tool on it. It found 6,000 problems.
And here is the crazy part. Somewhere in that pile were 231 lines that crash the moment they run! They point to classes that no longer exist. The only reason they had not crashed yet: nobody had walked down those paths in years.

How do you find 231 lines in a pile of 6,000? Not by reading the pile. 6,000 warnings is the same as zero. Nobody reads them. Nobody acts on them. And the tool gets switched off within two weeks.
A gate and a survey
So what saved the month? One decision: split the checker in two.
The gate. Easy to pass, and it runs on every change. It fails only on problems that are new. It passes today and must keep passing. Every old problem is put aside, by type.
The survey. The same checker, with the two biggest types of old problems switched back on. It never passes, and that is the point! It does not block anything. You open it when you are deciding what to fix next.
A gate you can pass and a survey you cannot are two different tools. Never make one setup do both jobs.
Trying to make one setup do both is why static analysis gets abandoned on old code. Every time. The gate is too strict to pass, or the survey is too quiet to learn from.
Will crash, might crash, cosmetic
Now the fun part. The real value was in the problems I had put aside. Every type got a count and a verdict: can this break when the code runs?

Look at the top line. That is the one that mattered. A reference to a class that does not exist is not a matter of style. It is a crash waiting for its first visitor.
6,000 warnings in one list is a reason to give up. The same 6,000, sorted into will crash, might crash and cosmetic? That is a plan.
Where AI agents help, and where they do not
Hand over the mechanical half. 53 of my commits that month are fixes done in batches. The work had a clear pattern. It was tedious. And every fix could be checked on its own. That is exactly the work to give AI agents, and wow, it went fast.
Keep the sorting. Is a warning cosmetic or deadly? To know, you need to know what the code does in real life. Which paths run every day. Which part has not been touched since its author left.
None of that is in the code. It is in the data, and in the heads of the people who were there.
What the month taught me
The month ended with something better than clean code. It ended with a map. Which of 6,000 warnings can actually hurt, ranked, with counts.
Did a map feel like enough? Not at first. A number like 6,000 pulls at you. You want to see it fall to zero. But the upgrade that comes next is a series of decisions about risk. And the map lets every one of them be made with open eyes.
This is true far beyond code. When a problem is too big to look at, the first job is not to fix it. It is to sort it, so you can see the few things that truly matter.
Old code is full of history, and history deserves respect, not panic. Most of those warnings were just the marks of 15 people doing their best over 10 years.
Do not try to get the number to zero. You will not, and chasing it burns the goodwill you need for the real work. Get the number sorted instead.
Things I did not expect
Which lines were the most dangerous? The quietest ones. The 231 broken references had sat there for years without a single crash. It felt like finding old wiring behind a wall that still looks freshly painted.
I did not expect a list of things I chose not to fix to be the most valuable file of the month. Usually that list is where problems go to be forgotten. Here it became the plan.
And I did not expect the AI agents to love the boring part so much. 53 fixes in batches, each one the same pattern as the last. Not one complaint!
6,000 complaints. Sorted. Now the code can be upgraded with its eyes open.
I post one of these every week. Follow along on LinkedIn or YouTube, or by RSS. Want this on your team? Work with me.
The 527 rules I give my AI agents, free
Every one comes from a real mistake. The best 100 are open on /rules, or download them as AGENTS.md, no email. All 527 come by email, as one file you can drop straight into your repo as AGENTS.md or CLAUDE.md, so your agents follow them from the next session. Plus the occasional email when I learn a new one.
One click to unsubscribe.