Skip to content

Say when a cycle report covers more modules than its example - #5

Merged
ChrisAbner merged 1 commit into
mainfrom
fix/cycle-message
Oct 28, 2026
Merged

ChrisAbner merged 1 commit into
mainfrom
fix/cycle-message

Conversation

@ChrisAbner

Copy link
Copy Markdown
Owner

Problem

The cycles rule reports each group of mutually reachable modules once, with the shortest cycle through its first module as an example. When the group is larger than that cycle, the message reads as if the example were the whole cycle:

Modules [Admin, Attribute, ... 30 modules] form a dependency cycle: Admin -> Product -> Admin.

Running Cordon on Bagisto (30 modules in the group), advisingapp (29) and LaravelEcomm (25) produced this message in all three.

Change

When the group has more modules than the example cycle, the message now says so:

Modules [Admin, Attribute, ...] are tangled in dependency cycles, such as Admin -> Product -> Admin. Break them one dependency at a time, for example with an event or a contract.
  • When the example covers every module (the common two-module case), the message is unchanged, so the README and docs examples stay valid.
  • The violation's target is unchanged, so existing baselines still match.
  • No contract, config or baseline format change.

Tests

  • New unit test for a three-module group whose shortest cycle has two modules (written first, seen failing).
  • The existing three-module test now also asserts the unchanged message.
  • composer check passes (Pint, PHPStan, Pest: 120 passed, 1 skipped).

Not in this PR

--module and the Pest expectation assign a cycle only to the modules on the example path (ADR 0005), so cordon:verify --module=Sales on Bagisto does not report the cycle Sales is part of. Changing that needs an ADR.

The cycles rule reports each strongly connected component once, with the
shortest cycle through its first module as the example. When the group is
larger than that cycle, "Modules [30 modules] form a dependency cycle:
A -> B -> A" read as a single two-module cycle. Running Cordon on Bagisto,
advisingapp and LaravelEcomm produced exactly that message in all three.

The message now says the modules "are tangled in dependency cycles, such
as A -> B -> A" in that case. When the example covers every module, the
message is unchanged. The violation's target stays the same, so existing
baselines still match.
@ChrisAbner
ChrisAbner merged commit a8d36a0 into main Oct 28, 2026
6 checks passed
@ChrisAbner
ChrisAbner deleted the fix/cycle-message branch October 28, 2026 04:14
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