Book Deep-Read · Software Engineering at Google · Chapter 20

Static Analysis

Software Engineering at Google · Ch 20 · Static Analysis · Caitlin Sadowski · 2020

中文 →

What is this chapter about?

Word processors have spell-check: before you hand in the essay, a red squiggle already sits under the typo. Code has the same thing, called "static analysis" — before the program ever runs, a machine reads the code and points out likely mistakes. This chapter is about how Google got tens of thousands of engineers to actually read those squiggles instead of ignoring all of them.

A strange thing first

You'd assume the smarter the checker and the more it catches, the better. Google found the opposite: once a tool is wrong one or two times out of ten, people learn to dismiss it without looking — and the few real warnings get thrown out with the rest. What decides whether a checker lives or dies is not how much it catches, but how rarely it cries wolf.

Why the old world was hard

Picture a smoke alarm that goes off every time someone cooks. By week three, the residents pull the battery — and on the day of a real fire, it stays silent. Early code checkers were like that: piles of reports, many of them mistaken or written so nobody understood them, usually delivered as a list of thousands with no clue who should fix what, or why now.

How it works, intuitively

What it bought / how to choose

The result: the system looks at more than fifty thousand changes a day, fewer than one in twenty of its notes are seen as "crying wolf", and authors accept a machine-made fix about three thousand times a day. The honest cost: to avoid crying wolf, it simply stays quiet about many "maybe, can't be sure" cases — it knowingly lets some real problems through in exchange for being listened to.

One line to remember

A code checker isn't better because it catches more. It should say a few accurate things, right after you've made a change and while a colleague is looking, and hand you the fix — only a trusted tool gets heard.

Want the definition of an "effective false positive", Tricorder's four admission criteria and feedback loop, why personal customization was removed, why the compiler never warns, and how to choose between the IDE, code review, presubmit and the compiler? → Switch to Deep read