Skip to content

refactor(listener): split the three object event handlers (REVIEW) - #1413

Merged
rubenvdlinde merged 2 commits into
developmentfrom
refactor/sig-stackiq-event-listener
Nov 3, 2026
Merged

rubenvdlinde merged 2 commits into
developmentfrom
refactor/sig-stackiq-event-listener

Conversation

@rubenvdlinde

@rubenvdlinde rubenvdlinde commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

REVIEW (this listener provisions organisations, contact person accounts and usage). Held. Behaviour-preserving refactor.

What

StackiqEventListener had three handlers:

handler lines McCabe params
handleObjectCreated 92 7 4
handleObjectUpdated 203 19 4
handleObjectDeleted 137 12 4

The change:

  • The handlers and dispatchEvent now take the event and one services array.
  • objectContext reads the object facts once.
  • firstMatchingSchema looks the catalog schemas up lazily, in the same order as before. The settings calls happen in the same sequence, and the lookup stops at the first match.
  • Each matched type goes to a small method.
  • The four contact person and contactgegevens update and deletion branches share runContactAction, with their log lines in a table.

Every call and every log line keeps its order and its text.

After: handleObjectCreated 51 lines (McCabe 6), handleObjectUpdated 50 (McCabe 6), handleObjectDeleted 35 (McCabe 3). Every new unit takes at most 2 parameters.

Evidence

  • Golden. StackiqEventListenerGoldenTest has 39 cases over handle(): created, updated and deleted events of every catalog type, active, inactive and unchanged organisations, refetch, sync and contact failures, unconfigured schemas, two types sharing a schema id, an Error from the contact person service escaping handle() (catch (\Exception) does not catch it, on both trees), and an organisation update with schema id "01" (both from RW118). It records every container, settings, contact person, sync, object service and logger call, with clock and trace values masked. It was recorded on the old code and passes on old and new.
  • Mutants. 20 of 20 killed: lazy lookup broken, first match versus last match, each type's branch dropped, inactive organisation synced, unchanged status synced, old status ignored, refetch result ignored, old object dropped from the update, update calling the deletion, contact failure escaping, deletion lookup order, log lines swapped. The no-op control survived.

Stale test removed

StackiqEventListenerTest skipped all 12 of its cases in setUp(). They were written against a constructor and service calls that the listener no longer has. The golden test covers the current dispatch, so the stale file is deleted. That removes 12 of the app's 59 skipped tests.

Numbers (PHP, lizard, against development)

development this PR
params >= 3 16.95% 15.85%
size > 60 33.98% 33.05%
McCabe > 10 18.28% 17.52%

Verified locally

  • Diff-scoped checks on every touched lib file: php -l, phpcs, phpstan, psalm and phpmd are clean.
  • The touched tests pass under pcov with --fail-on-risky (exit 0).
  • development (ea0dcc2) is merged in, without a rebase.
  • The full unit suite ran once through heavy.sh (phpunit-unit.xml, pcov, --fail-on-risky): exit 0, 1609 tests, 0 failures, 0 risky, 59 skipped (inherited).
  • The hydra gates run (--scope-to-diff --base origin/development) is queued. Its result follows in a comment.

Assisted-by: ClaudeCode:claude-opus-5-5

handleObjectCreated (92 lines), handleObjectUpdated (203) and
handleObjectDeleted (137) took the event plus three services. They now take
the event and one services array, read the object facts once
(objectContext), look the catalog schemas up lazily in the same order
(firstMatchingSchema), and hand each matched type to a small method. The
contact person and contactgegevens update and deletion branches share
runContactAction with their log lines in a table. Every call and log line
keeps its order and text.

Golden: 37 cases over handle() for created, updated and deleted events of
every catalog type, with sync, refetch and contact failures, recorded on the
old code.

Assisted-by: ClaudeCode:claude-opus-5-5
@rubenvdlinde
rubenvdlinde marked this pull request as ready for review November 3, 2026 17:37
…op the stale skipped test

Two golden cases from review, recorded on the old code: an Error from the
contact person service escapes handle() (catch (\Exception) does not catch it),
and an organisation update with schema id "01" matches schema 1.

StackiqEventListenerTest skipped all 12 of its cases in setUp(): they were
written against a constructor and service calls the listener no longer has.
The golden test covers the current dispatch, so the stale file goes.

Assisted-by: ClaudeCode:claude-opus-5-5
@rubenvdlinde

Copy link
Copy Markdown
Contributor Author

Rerun with the two golden cases and the stale test removed: full unit suite (pcov, --fail-on-risky) exit 0, 1599 tests, 0 failures, 0 risky, 47 skipped (12 fewer skips: the stale StackiqEventListenerTest is gone).

@rubenvdlinde

Copy link
Copy Markdown
Contributor Author

Hydra gates --scope-to-diff --base origin/development (through heavy.sh): 33 of 33 applicable gates ran, 0 FAIL.

@rubenvdlinde
rubenvdlinde merged commit 3604e5b into development Nov 3, 2026
39 of 42 checks passed
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Quality Report — ConductionNL/stackiq @ e6ed707

Check PHP Vue Security License Tests
lint ✅
phpcs ✅
phpmd ✅
psalm ✅
phpstan ✅
phpmetrics ✅
eslint ✅
stylelint ✅
build ✅
check-manifest ✅
check-vue-demi ✅
test-l10n ✅
format ✅
check-schema-l10n ❌
check-l10n-js ✅
composer ✅ ✅ 127/127
npm ❌ ✅ 807/807
app:check-code ⏭️
info.xml ✅
REUSE ❌
lockfile sync ✅
PHPUnit ✅ 1591/1591 · 8 skipped
Newman ⏭️
Playwright ⏭️ deferred: E2E runs locally and on the promotion path only. This pull request targets development, so the suite is asked once per promotion into beta and main rather than once per push per open pull request. Run it locally with npx playwright test, or from the Actions tab on a branch with no open pull request into development.
Hydra gates ❌

Quality workflow — 2026-11-04 00:56 UTC

Download the full PDF report from the workflow artifacts.

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