Fix Credo Readability (strict)
- Max line length, implicit try, alias order, zero-arity defs - String sigils, long comments split; redundant blank lines fixed
This commit is contained in:
parent
f0a8dfcc21
commit
81ce204502
48 changed files with 131 additions and 144 deletions
|
|
@ -21,49 +21,47 @@ defmodule MvWeb.RoleLive.Show do
|
|||
|
||||
@impl true
|
||||
def mount(%{"id" => id}, _session, socket) do
|
||||
try do
|
||||
case Ash.get(
|
||||
Mv.Authorization.Role,
|
||||
id,
|
||||
domain: Mv.Authorization,
|
||||
actor: socket.assigns[:current_user]
|
||||
) do
|
||||
{:ok, role} ->
|
||||
user_count = load_user_count(role, socket.assigns[:current_user])
|
||||
case Ash.get(
|
||||
Mv.Authorization.Role,
|
||||
id,
|
||||
domain: Mv.Authorization,
|
||||
actor: socket.assigns[:current_user]
|
||||
) do
|
||||
{:ok, role} ->
|
||||
user_count = load_user_count(role, socket.assigns[:current_user])
|
||||
|
||||
{:ok,
|
||||
socket
|
||||
|> assign(:page_title, gettext("Show Role"))
|
||||
|> assign(:role, role)
|
||||
|> assign(:user_count, user_count)
|
||||
|> assign(:show_delete_modal, false)}
|
||||
{:ok,
|
||||
socket
|
||||
|> assign(:page_title, gettext("Show Role"))
|
||||
|> assign(:role, role)
|
||||
|> assign(:user_count, user_count)
|
||||
|> assign(:show_delete_modal, false)}
|
||||
|
||||
{:error, %Ash.Error.Invalid{errors: [%Ash.Error.Query.NotFound{} | _]}} ->
|
||||
{:error, %Ash.Error.Invalid{errors: [%Ash.Error.Query.NotFound{} | _]}} ->
|
||||
{:ok,
|
||||
socket
|
||||
|> put_flash(:error, gettext("Role not found."))
|
||||
|> redirect(to: ~p"/admin/roles")}
|
||||
|
||||
{:error, error} ->
|
||||
{:ok,
|
||||
socket
|
||||
|> put_flash(:error, format_error(error))
|
||||
|> redirect(to: ~p"/admin/roles")}
|
||||
end
|
||||
rescue
|
||||
e in [Ash.Error.Invalid] ->
|
||||
# Handle exceptions that Ash.get might throw (e.g., policy violations)
|
||||
case e do
|
||||
%Ash.Error.Invalid{errors: [%Ash.Error.Query.NotFound{} | _]} ->
|
||||
{:ok,
|
||||
socket
|
||||
|> put_flash(:error, gettext("Role not found."))
|
||||
|> redirect(to: ~p"/admin/roles")}
|
||||
|
||||
{:error, error} ->
|
||||
{:ok,
|
||||
socket
|
||||
|> put_flash(:error, format_error(error))
|
||||
|> redirect(to: ~p"/admin/roles")}
|
||||
_ ->
|
||||
reraise e, __STACKTRACE__
|
||||
end
|
||||
rescue
|
||||
e in [Ash.Error.Invalid] ->
|
||||
# Handle exceptions that Ash.get might throw (e.g., policy violations)
|
||||
case e do
|
||||
%Ash.Error.Invalid{errors: [%Ash.Error.Query.NotFound{} | _]} ->
|
||||
{:ok,
|
||||
socket
|
||||
|> put_flash(:error, gettext("Role not found."))
|
||||
|> redirect(to: ~p"/admin/roles")}
|
||||
|
||||
_ ->
|
||||
reraise e, __STACKTRACE__
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@impl true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue