elixir/.credo/README.md
This directory contains custom Credo checks specific to the Firezone codebase.
Ensures that Ecto schema modules define a changeset/1 function that accepts an Ecto.Changeset.
Rationale: We expect the caller to be able to pass in an already-created changeset for validation, ensuring a consistent pattern across the codebase.
Exceptions:
embedded_schema do blocks) typically use changeset/2 insteadExample:
defmodule Portal.Account do
use Ecto.Schema
import Ecto.Changeset
schema "accounts" do
field :name, :string
timestamps()
end
def changeset(changeset) do
changeset
|> validate_required([:name])
|> validate_length(:name, min: 3, max: 64)
end
end
Prevents the use of action_fallback macro in controllers. Use explicit error handling with Error.handle/2 instead.
Restricts direct Portal.Repo calls to specific contexts (Portal.Safe module, seeds, tests, migrations).
Validates that database functions are properly isolated.
Ensures proper Portal.Safe aliasing in modules that need it.
Prevents cross-module database operations to maintain proper boundaries.
# Run all Credo checks
mix credo --strict
# Run only custom checks
mix credo --only MissingChangesetFunction
# Run Credo in CI
# Checks are automatically run in the GitHub Actions workflow
.credo/check/warning/ or .credo/check/consistency/.credo.exs in both the requires and checks.enabled sections