Skip to content

ci: growth guards for PowerShell, JavaScript, duplication and docs - #166

Merged
eizedev merged 2 commits into
mainfrom
ci/growth-guards
Nov 22, 2026
Merged

eizedev merged 2 commits into
mainfrom
ci/growth-guards

Conversation

@eizedev

@eizedev eizedev commented Nov 22, 2026

Copy link
Copy Markdown
Owner

Summary

TL;DR: CI now fails when a PowerShell file or function, a JavaScript function, duplicated JavaScript or a docs page grows past its limit. Today's offenders are in build/growth-baseline.json and may only shrink.

npm run growth runs build/growth.js. It works like scripts/growth.js in eizedev/pivotkit. Each guard is its own step in the javascript job.

Guard Measures Limit
powershell code lines per .ps1/.psm1 and per function, with the PowerShell parser (build/Measure-PowerShellSize.ps1) file 300, function 100
javascript lines and complexity per function in modules/*/Components and shared/js, with ESLint 120 lines, complexity 25 (as pivotkit)
duplication copied JavaScript in the same folders, with jscpd 0.3 % (today 0.21 %)
docs lines per docs page and README by kind, and their total overview 150, topic 200, reference 100, README 80; total ±2 %

Rules:

  • A new or grown offender fails. The message says what to do.
  • A smaller offender fails until node build/growth.js --update lowers the baseline in the same pull request.
  • --update --accept-growth raises an entry. The pull request then says why.
  • Code lines skip blank lines and comments, so comment-based help costs nothing.
  • Functions are keyed by name (anonymous JavaScript functions by file). Moving one into Public/ (pivot: split the 4,948-line module into Public/Private files and small functions #163) or another file keeps its entry.
  • A red step runs even when an earlier step failed, and its message says how to split, or how to raise the baseline when the growth is right.
  • ESLint runs without inline config, so an eslint-disable comment cannot hide a function.

Baseline:

  • PowerShell files: Pivot.psm1 2731, PivotReport.Tests.ps1 1409, ECharts Showcase.ps1 1331, PivotTemplates.Tests.ps1 728, Pivot.Tests.ps1 530, docs/site/examples.ps1 510, ECharts.psm1 329, Pivot Showcase.ps1 305.
  • PowerShell functions: New-UDPivotReport 267, New-UDEChart 193, Invoke-UDPivotTemplateStore 158, Invoke-UDPivotReport 150.
  • JavaScript lines: cartesian 337, EChart 277 and an arrow function in it 127, PsuPivotReport 260, Perspective 139.
  • JavaScript complexity: cartesian 46, PsuPivotReport 39, responsive 38, an arrow function in buildOption.js 35, histogram 27, formatter 26.
  • Docs: pivot/templates.md 548, pivot/reports.md 416, pivot/index.md 264, pivot/views.md 238, pivot/server-rows.md 208, README.md 105; total 4134.
  • Duplication: one clone of 13 lines in buildOption.js (lines 1293 and 1775).

What to know:

  • PSScriptAnalyzer has no rule for file or function length, and I found no common number for PowerShell. The limits start where the outliers begin.
  • Lines are a weak measure for docs: a long line counts once. The examples included from docs/site/generated/ do not count.
  • The docs total is one number in the baseline. Two pull requests that each shorten the docs can pass alone and cross the margin together; the next run then asks for --update.
  • New dev dependencies, exact pins: eslint 10.15.0, jscpd 5.4.3 (the versions pivotkit uses).

Found on the way: #165. The bundle folder public/ collides with Public/ of the split on macOS and Windows.

Places checked: AGENTS.md (Layout, Commands), CONTRIBUTING.md (links to AGENTS.md), docs/development, README. No module changes, so no CHANGELOG entry.

Refs #163

Test plan

  • npm test (JavaScript), with tests/js/growth.test.js
  • Invoke-Pester -Path tests/powershell, with tests/powershell/Growth.Tests.ps1
  • PSScriptAnalyzer as CI runs it: no findings
  • node build/growth.js: all four ok; one line added to a page fails, one line removed fails until --update (also covered by tests/js/growth.test.js)
  • Neutral review of the change; its findings are fixed except the ones under "What to know"
  • ./build/Build-Module.ps1 -Module <Module> builds: no module changed
  • Checked on a PSU instance: no component changed
  • CHANGELOG.md of the module updated: no module changed

🤖 Generated with Claude Code

eizedev and others added 2 commits November 22, 2026 17:59
build/growth.js checks four ratchets against build/growth-baseline.json, one
CI step each: code lines per PowerShell file and function (parsed with the
PowerShell AST in build/Measure-PowerShellSize.ps1), lines and complexity per
JavaScript function (ESLint), duplicated JavaScript (jscpd, fixed threshold)
and lines per docs page and README by kind. A new or grown offender fails, a
smaller one fails until the baseline is lowered in the same pull request.
Mirrors scripts/growth.js of eizedev/pivotkit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Named JavaScript functions are keyed by name, so a move to another
  file keeps the entry, as for PowerShell.
- Every grown guard says how to raise the baseline when the growth is
  right; the docs advice covers the total.
- The guard steps run when an earlier step failed.
- Measure-PowerShellSize.ps1 measures hidden folders on every platform
  and leaves out class methods.
- Tests for the command's exit codes and --update, filters, class
  methods and hidden folders.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@eizedev
eizedev merged commit 27ab486 into main Nov 22, 2026
19 of 20 checks passed
@eizedev
eizedev deleted the ci/growth-guards branch November 22, 2026 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant