# `Bylaw.Credo.Check.HEEx.NoIndirectAssignAccess`
[🔗](https://github.com/ryanzidago/bylaw/blob/v0.4.0/lib/bylaw/credo/check/heex/no_indirect_assign_access.ex#L1)

## Basics

> #### This check is disabled by default. {: .neutral}
>
> [Learn how to enable it](`e:credo:config_file.html#checks`) via `.credo.exs`.

This check has a base priority of `high` and works with any version of Elixir.

## Explanation

Discourages indirect access to the special HEEx `assigns` variable.

Avoid:

    ~H"<h1>{Map.get(assigns, :title)}</h1>"

    ~H"<h1>{assigns[:title]}</h1>"

Initialize the assign before rendering and access it directly:

    ~H"<h1>{@title}</h1>"

Direct access makes the template's inputs visible and requires missing values
to be handled at the rendering boundary. This check reports literal keys in
both two- and three-argument `Map.get` calls, as well as bracket access. It
ignores dynamic keys because they cannot be safely rewritten to direct HEEx
assign access.

Embedded `~H` templates are checked during normal Credo runs over Elixir
files. Standalone `.html.heex` templates require enabling
`Bylaw.Credo.Plugin.HEExSources`.

Configure this check with an empty option list:

    {Bylaw.Credo.Check.HEEx.NoIndirectAssignAccess, []}

## Check-Specific Parameters

*There are no specific parameters for this check.*

## General Parameters

Like with all checks, [general params](`e:credo:check_params.html`) can be applied.

Parameters can be configured via the [`.credo.exs` config file](`e:credo:config_file.html`).

---

*Consult [api-reference.md](api-reference.md) for complete listing*
