Code review and ensemble programming
This section reviews another area surprisingly resistant to automation: checking code quality.
As we’ve seen throughout this book, TDD is primarily concerned with the design of our code. As we build up a unit test, we define how our code will be used by its consumers. The implementation of that design is of no concern to our test, but it does concern us as software engineers. We want that implementation to perform well and to be easy for the next reader to understand. Code is read many more times than it is written over its life cycle.
Some automated tools exist to help with checking code quality. These are known as static code analysis tools. The name comes from the fact that they do not run code; instead, they perform an automated review of the source code. One popular tool for Java is Sonarqube (at https://www.sonarqube.org/), which runs a set of rules across a code base.
Out of the box, tools like this give warnings about the...