ArchTest.Violation (ArchTest v0.2.0)

Copy Markdown View Source

Represents a single architecture rule violation.

Violations are collected during rule evaluation and reported as ExUnit assertion failures with human-readable messages.

Summary

Functions

Builds a :cycle violation.

Builds an :existence violation (module should not exist).

Builds a :forbidden_dep violation.

Formats a single violation into a human-readable string.

Formats a list of violations into a human-readable string for ExUnit output.

Builds a :naming violation.

Builds a :forbidden_dep violation with a transitive path shown.

Types

t()

@type t() :: %ArchTest.Violation{
  callee: module() | nil,
  caller: module() | nil,
  message: String.t(),
  module: module() | nil,
  path: [module()] | nil,
  type: violation_type()
}

violation_type()

@type violation_type() ::
  :forbidden_dep
  | :missing_dep
  | :naming
  | :existence
  | :cycle
  | :metric
  | :custom

Functions

cycle(cycle_path, reason)

@spec cycle([module()], String.t()) :: t()

Builds a :cycle violation.

existence(mod, reason)

@spec existence(module(), String.t()) :: t()

Builds an :existence violation (module should not exist).

forbidden_dep(caller, callee, reason)

@spec forbidden_dep(module(), module(), String.t()) :: t()

Builds a :forbidden_dep violation.

format(v)

@spec format(t()) :: String.t()

Formats a single violation into a human-readable string.

format_all(violations)

@spec format_all([t()]) :: String.t()

Formats a list of violations into a human-readable string for ExUnit output.

Groups violations by offending module where possible and adds visual separators for readability.

naming(mod, reason)

@spec naming(module(), String.t()) :: t()

Builds a :naming violation.

transitive_dep(caller, callee, path, reason)

@spec transitive_dep(module(), module(), [module()], String.t()) :: t()

Builds a :forbidden_dep violation with a transitive path shown.