Soundcheck.Check.Warning.InvalidSendUpdate (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 high and works with any version of Elixir.

Explanation

Flags send_update/2,3 and send_update_after/3,4 calls that cannot reach a LiveComponent: the assigns name a module but carry no :id, which raises ArgumentError, or the module is a LiveView or a plain module. No rendered component matches such a module, so LiveView drops the update with only a debug log, or raises when the module does not exist.

Before:

send_update(MyAppWeb.PostLive.Index, id: "post-form", post: post)

After:

send_update(MyAppWeb.PostLive.FormComponent, id: "post-form", post: post)

The module must be a literal alias or __MODULE__, expanded as the calling module expands it, and the :id check needs literal assigns (a keyword list or map). Calls targeting @myself or another CID are skipped.

Confidence: high. Tier: semantic for the module check (run mix compile before mix credo); the :id check 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.