With the release of Drupal 8, it is apparent that improvements in speed and stability of development is needed1. However, the reality of this challenge is daunting: at over a million lines of code and with hundreds of lines in core and module code being added, removed, and modified every month by contributors all around the world, any improvements will take significant time and effort to coordinate. Thanks to developments in academia and automation tools developed by the PHP community, we have an easy win: static analysis.
To know how to improve, we need to start with understanding where we are. The speed of Drupal development is being hindered by the "noise" of bug tickets, the time to triage a bug to identify its cause, the time to resolve conflicts between patches, rework required due to close coupling, onboarding time for new contributors, and the time it takes to reach consensus on changes. Stability of development is hindered by code being hard to test, high coupling, and high complexity. Static analysis is an automated process that can surface improvements in all of these aspects.
Static analysis with Code Climate provides a free and objective way to discover error-prone and incorrect code. Initiative leads can do design reviews using coupling and complexity metrics to understand which areas of the system are most difficult to test and extend. Early contributors can quickly assist with resolving code style violations, adding missing documentation, and removing unused or duplicate code. Core and module maintainers can get warnings of code that poses a risk for bugs or security holes such as unused variables or references to superglobals. Site builders can use churn and quality metrics to compare the stability of different modules. Thus, we have an automated way to find and prevent bugs and identify and quantify improvements.
As a result the speed and stability of development is improved through fewer bugs, cleaner code that is easier to test and maintain, and greater flexibility and extensibility by better adhering to SOLID software design2. There are a predicted 1,500 bugs in Drupal 8 core3. Projects with large code bases, such as the Linux kernel and Windows server, are using static analysis tools like Code Climate to proactively resolve those bugs and improve quality, keep their teams operating at speed and their releases stable4. While other efforts in the Drupal community will arise to address these development needs, doing static analysis with Code Climate gives us clear and immediate direction we can act on.
1. The need for speed and stability of development is derived from the "Drupal 8 Retrospective Suggestions" Google Doc survey results.
2. For an explanation of SOLID software design, see the "SOLID (object-oriented design)" article on WikiPedia.
3. To compute this, take the "bugs" column on the "Explore" tab of the phpmetrics results for Drupal Core 8.0.6 and multiply it by the number of files on the "Evaluation" tab. The math, then, is: 0.46 bugs * 3,373 files = 1,551.58 bugs.
4. The Linux kernel and Windows server teams found static analysis to have a 0.56 and 0.58 correlation with bug reports, see "Linux Kernel Developer Responses to Static Analysis Bug Reports" by Philip J. Guo and Dawson Engler from Stanford University for details.