The codebase metrics page (docs/metrics.md) has been maintained by hand, so its numbers and its inline SVG charts drift from the code between refreshes. This adds a committed generator that produces the whole page from measured data, and regenerates the page from it.

What this does

  • Adds scripts/generate-metrics.php: it reads the per-file JSON from cloc on stdin and writes docs/metrics.md (prose, tables and inline SVG charts) from a set of documented counting rules. Every number and bar is derived; nothing on the page is hand-maintained.
  • Regenerates docs/metrics.md from the current 1.x. The per-submodule breakdown now sums exactly to the totals (the hand-made page left a small unattributed remainder), services count service definitions only (aliases excluded), and plugins are counted by class.

Security

The committed script executes no commands (no shell_exec, exec, system, passthru, proc_open, popen or eval), refuses to run outside the CLI, does all file discovery with native PHP filesystem APIs, and only reads files plus writes the single docs/metrics.md. You run cloc yourself and pipe its JSON in; the script never invokes it.

Usage

From the module root:

cloc --exclude-dir=node_modules --by-file --json --quiet . | php scripts/generate-metrics.php

Issue fork orchestra-3608539

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mably created an issue. See original summary.

mably’s picture

Status: Active » Needs review

Opened MR !290 against 1.x: adds scripts/generate-metrics.php and regenerates docs/metrics.md from it.

The script executes no commands and is CLI-only; it reads the per-file JSON from cloc on stdin and writes the single docs/metrics.md, discovering files with native PHP. Verified locally: php -l, phpcs and cspell all clean. Setting to Needs review pending CI.

  • mably committed abc1682e on 1.x
    task: #3608539 Generate the codebase metrics page from a committed...
mably’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.