dependency-cycle
Packages of the project depend on each other in a cycle.
- Group
- Code
- Runs
- Optional: run it with
ur lint --rule dependency-cycle - Level
- warning
- Reads
- Every file
- Fix
- None: which dependency to remove, and where its code goes, is a design choice
Why
The project's packages depend on each other in a cycle, so none of them can be built, tested, or understood without all the others. Cargo refuses a cycle of normal dependencies but allows one through a dev-dependency; npm and Python workspaces allow any. The rule runs where an [architecture] table in .ur/ur.toml declares the project's architecture, unless it says acyclic = false, and its kinds limit it to some kinds of dependency. Each set of packages in cycles is reported once, through its shortest cycle.
The fix, as Ur suggests it: break the cycle by moving what the packages share into a package below them.
For agents
Never make a package depend on one that depends on it, directly or through others; move what both need into a package below them.
Example
.ur/ur.toml[architecture.components]
billing = ["orders", "invoices"]
orders/pyproject.toml[project]
name = "orders"
dependencies = ["invoices"]
invoices/pyproject.toml[project]
name = "invoices"
dependencies = ["orders"]
orders/orders/__init__.pyfrom invoices import issue
def place(order):
return issue(order)
$ ur lint --rule dependency-cycle
warning[dependency-cycle]: 2 packages depend on each other in a cycle: `invoices` -> `orders` -> `invoices`; without `orders` -> `invoices`, no cycle is left
--> invoices/pyproject.toml:3:1 `invoices` depends on `orders`
= step 1: orders/pyproject.toml:3:1 `orders` depends on `invoices`
= hint: break the cycle by moving what the packages share into a package below them
0 clone classes and 1 `dependency-cycle` finding in 3 files