Basics
This check is disabled by default.
Learn how to enable it via .credo.exs.
This check has a base priority of high and works with any version of Elixir.
Explanation
Using ^Date.utc_today() or ^DateTime.utc_now() inside an Ash
expression freezes the value at compile time. The pinned value never
changes after compilation, leading to subtle bugs that only show up
after time passes.
Use Ash's built-in expression functions instead:
# Bad - frozen at compile time
filter expr(start_date <= ^Date.utc_today())
# Good - evaluated at runtime
filter expr(start_date <= today())
# Bad
filter expr(inserted_at >= ^DateTime.utc_now())
# Good
filter expr(inserted_at >= now())Only expressions in DSL position are checked. Inside function
bodies and anonymous functions the pin is re-evaluated on every call
(Ash.Expr.expr/1 splices the pinned code into its call site), so
the value is not frozen there and is not flagged.
Check-Specific Parameters
There are no specific parameters for this check.
General Parameters
Like with all checks, general params can be applied.
Parameters can be configured via the .credo.exs config file.