SQLite: A Lesson In Low-Defect Software (review/summary w/ working source)
aleccolocco.blogspot.com
aleccolocco.blogspot.com
By contrast, both the Linux kernel and WebKit are far more beautiful codebases than SQLite, and also deal with far more complexity. If SQLite's the best you've seen, you haven't really seen much...
So, even if naming conventions are inconsistent and there's not enough whitespace, it is still a nice piece of code. The interfaces are very nice and clean (which does apply to internally used interfaces, as well, as I recall it), which is extremely important. It is also among the best tested pieces of C code in the world, with ridiculously high test coverage, which is good, too...it also means it is better documented than a lot of code, since the tests tend to provide a second tier of code documentation (you can see how the interface, both internal and world-facing, is used and what it's supposed to return).
I won't argue that Linux or WebKit aren't nicer. I've spent more time in the Linux kernel sources than any other major C project (except maybe Squid), and it is definitely a really great codebase. I don't know WebKit, at all, so won't comment. Linux has dramatically less test coverage than SQLite, and is also tersely commented and documented. I kinda suspect your opinion of the SQLite bits that are poorly commented comes from the contrast with the places where it is commented in vivid and verbose detail (I seem to recall there was/is some form of literate programming going on in SQLite, but maybe that was another project).
I think these are only two of many techniques for improving code quality. Code reviews, in my experience, are also a huge plus.
That seems like a very humble goal, and yet they strive for that level of quality.
The reason why it is done with quality is because the developers really wanted to.