# `Soundcheck.Check.Warning.PatchToForeignLiveView`
[🔗](https://github.com/leonqadirie/soundcheck/blob/v0.1.0/lib/soundcheck/check/warning/patch_to_foreign_live_view.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

Flags `push_patch` to a path whose live route renders a different
LiveView. A patch keeps the current LiveView and only calls
`handle_params/3`, so LiveView raises when the server pushes one that
points elsewhere. Use `push_navigate` for another LiveView. A
client-side patch (`<.link patch={...}>`, `JS.patch`) to another
LiveView does not raise: LiveView falls back to navigating there.

Before:

    # in MyAppWeb.PostLive.Index
    {:noreply, push_patch(socket, to: ~p"/users/#{user}")}

After:

    {:noreply, push_navigate(socket, to: ~p"/users/#{user}")}

Only literal paths and `~p` sigils are checked, and only in a
LiveView's own functions. An interpolation
inside `~p` matches any one route segment; one in a plain string
matches any number of them, because the value can hold slashes. The
check reports only when every matching live route renders another
LiveView.

Confidence: high. Tier: semantic (run `mix compile` before `mix credo`).

## 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](`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*
