Hold your code to architecture rules

Choose the rules your code must keep, such as "The web never calls a database directly", and read each break with its file and line.

In short

Architecture rules say how your code must be built, such as "Every endpoint checks a permission". {{brand}} checks them on every reading of your code and in the pull request check. A break of a rule at "Fail" fails the check; at "Warn" it is only shown. The breaks are listed under Review › Problems, with the file and line.

Before you start

Steps

  1. On the Designer home, open the header menu and choose "Architecture rules".
  2. Under "Ready-made rules", set each rule to "Off", "Warn" or "Fail".
  3. To add your own, under "Your rules" press "Custom rule", "Only some parts write a table" or "No call between two kinds of part".
  4. Say who the rule is about under "Parts" and "Other parts", by "Kind", "Layer", "Area" or "Service". A custom rule also takes "Must or must not" and "What they do".
  5. Press "Save rules".

Result: "Rules saved." The next reading of your code is checked against them.

  1. Open a design, choose "Review" and then "Problems".
  2. At the top of the panel, choose "Rules". The line below counts how many fail and how many warn.
  3. Read each break: the part, the rule, why it breaks and the file and line. Failing breaks come first.
  4. Press "Show Orders API on the canvas" to select the part, where this design draws it.

Allow an exception

  1. In "Architecture rules", press "Add an exception" under the rule.
  2. Type the "Part key, route or file glob" and "Why".
  3. Press "Save rules".

Result: the break is listed last, with "excepted:" and your reason, and is never counted.

Good to know

If something goes wrong

Related