Soundcheck.Check.Readability.AssignsDotAccess (soundcheck v0.1.0)

Copy Markdown View Source

Basics

This check is disabled by default.

Learn how to enable it via .credo.exs.

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

Explanation

Flags assigns.key in template expressions where @key is the idiomatic spelling. LiveView tracks both the same way, so this is a consistency rule, not a performance one.

Before:

<p>{assigns.title}</p>

After:

<p>{@title}</p>

assigns[:key] is not reported: it returns nil for a missing key where @key raises, so the two are not interchangeable.

Confidence: high. Tier: syntactic (works without compiling).

Check-Specific Parameters

Use the following parameters to configure this check:

:excluded_paths

Paths to skip (atoms, binaries as path segments, or regexes).

This parameter defaults to [~r/\/test\//, "test"].

:strict

Unused.

This parameter defaults to false.

General Parameters

Like with all checks, general params can be applied.

Parameters can be configured via the .credo.exs config file.