A dashboard that tracks Drupal core's codebase over time: lines of code, complexity, maintainability, anti-patterns, and API surface area.
View the dashboard: https://dbuytaert.github.io/drupal-core-metrics/
Learn more: Measuring Drupal Core code complexity
- SLOC: Source lines of code (excluding blanks and comments)
- Cyclomatic complexity: Decision paths in code. Lower is simpler.
- Maintainability index: 0-100 score. Higher is easier to maintain.
Code patterns with known downsides. Tracked per 1k lines.
| Pattern | Description |
|---|---|
| Magic keys | #-prefixed array keys. Inherent to Drupal's render array architecture. |
| Deep arrays | 3+ levels of nesting. Hard to read and refactor. |
| Service locators | \Drupal::service() calls. Hides dependencies, hinders testing. |
Distinct extension points in Drupal. A larger surface may correlate with a steeper learning curve.
| Category | Examples |
|---|---|
| Plugin types | Block, Field, ViewsDisplay |
| Hooks | hook_form_alter, hook_entity_presave |
| Magic keys | #theme, #states, #ajax (vocabulary size) |
| Events | KernelEvents::REQUEST |
| Services | cache, entity, router |
| YAML formats | routing, permissions, services |
Prerequisites: PHP 8.1+, Python 3, Composer
composer install # Install dependencies
python3 scripts/analyze.py # Run analysis (15-30 min)This generates data.json. The index.html file is static and does not need to be regenerated.
The dashboard loads data via fetch(), which requires an HTTP server (browsers block this for local files). Start a simple server:
python3 -m http.server 8000Then open http://localhost:8000 in your browser.
Questions or ideas? Open an issue or PR.