Various refactoring and typespec improvements
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -94,7 +94,7 @@ defmodule Mix.Tasks.Mobilizon.Actors.New do
|
||||
{:admin, nil} ->
|
||||
shell_error("Profile with username #{Keyword.get(options, :group_admin)} wasn't found")
|
||||
|
||||
{:error, :insert_group, %Ecto.Changeset{errors: errors}, _} ->
|
||||
{:error, %Ecto.Changeset{errors: errors}} ->
|
||||
shell_error(inspect(errors))
|
||||
shell_error("Error while creating group because of the above reason")
|
||||
end
|
||||
|
||||
@@ -50,6 +50,8 @@ defmodule Mix.Tasks.Mobilizon.Actors.Utils do
|
||||
new_person
|
||||
end
|
||||
|
||||
@spec create_group(Actor.t(), String.t(), String.t(), Keyword.t()) ::
|
||||
{:ok, Actor.t()} | {:error, Ecto.Changeset.t()}
|
||||
def create_group(%Actor{id: admin_id}, username, name, _options \\ []) do
|
||||
{username, name} = username_and_name(username, name)
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ defmodule Mix.Tasks.Mobilizon.Ecto do
|
||||
@doc """
|
||||
Ensures the given repository's migrations path exists on the file system.
|
||||
"""
|
||||
@spec ensure_migrations_path(Ecto.Repo.t(), Keyword.t()) :: String.t()
|
||||
@spec ensure_migrations_path(Ecto.Repo.t(), Keyword.t()) :: String.t() | no_return
|
||||
def ensure_migrations_path(repo, opts) do
|
||||
path = opts[:migrations_path] || Path.join(source_repo_priv(repo), "migrations")
|
||||
|
||||
@@ -39,6 +39,7 @@ defmodule Mix.Tasks.Mobilizon.Ecto do
|
||||
Path.join(Application.app_dir(:mobilizon), priv)
|
||||
end
|
||||
|
||||
@spec raise_missing_migrations(String.t(), Ecto.Repo.t()) :: no_return
|
||||
defp raise_missing_migrations(path, repo) do
|
||||
raise("""
|
||||
Could not find migrations directory #{inspect(path)}
|
||||
|
||||
@@ -71,7 +71,7 @@ defmodule Mix.Tasks.Mobilizon.Users.Clean do
|
||||
end)
|
||||
end
|
||||
|
||||
@spec result(boolean(), boolean()) :: :ok
|
||||
@spec result(boolean(), non_neg_integer()) :: :ok
|
||||
defp result(dry_run, nb_deleted_users) do
|
||||
if dry_run do
|
||||
shell_info("#{nb_deleted_users} users would have been deleted")
|
||||
|
||||
Reference in New Issue
Block a user