Skip to content

Commit

Permalink
chore: fix dialyzer issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Gladear committed Feb 17, 2024
1 parent 2301028 commit cb68b23
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 22 deletions.
7 changes: 6 additions & 1 deletion apps/app/lib/app/accounts/avatars.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ defmodule App.Accounts.Avatars do
Uses Gravatar as the default avatar provider.
"""

@type entity() :: %{
:email => binary(),
optional(atom()) => any()
}

@doc """
Get the avatar URL for an entity. Currently, only entities with an `:email`
field are supported.
Expand All @@ -15,7 +20,7 @@ defmodule App.Accounts.Avatars do
"https://www.gravatar.com/avatar/7671d949664fc1fbce03b4ee41c509a4"
"""
@spec avatar_url(%{email: binary()}) :: String.t()
@spec avatar_url(entity()) :: String.t()
def avatar_url(%{email: email}) do
gravatar_email_url(email)
end
Expand Down
1 change: 1 addition & 0 deletions apps/app/lib/app/balance.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ defmodule App.Balance do
alias App.Repo

alias App.Transfers
alias App.Books.BookMember

@doc """
Compute the `:balance` field of book members.
Expand Down
14 changes: 7 additions & 7 deletions apps/app/lib/app/balance/balance_config.ex
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,14 @@ defmodule App.Balance.BalanceConfig do
@type id :: integer()

@type t :: %__MODULE__{
id: id(),
id: id() | nil,
annual_income: non_neg_integer() | nil,
owner: User.t(),
owner_id: User.id(),
created_for: :user | :book_member,
start_date_of_validity: DateTime.t(),
inserted_at: NaiveDateTime.t(),
updated_at: NaiveDateTime.t()
owner: User.t() | Ecto.Association.NotLoaded.t(),
owner_id: User.id() | nil,
created_for: :user | :book_member | nil,
start_date_of_validity: DateTime.t() | nil,
inserted_at: NaiveDateTime.t() | nil,
updated_at: NaiveDateTime.t() | nil
}

@derive {Inspect, only: [:id, :owner, :owner_id]}
Expand Down
2 changes: 1 addition & 1 deletion apps/app/lib/app/books.ex
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ defmodule App.Books do
end

# Returns a query that fetches all books a user belongs to.
@spec books_of_user_query(Auth.User.t()) :: Ecto.Query.t()
@spec books_of_user_query(User.t()) :: Ecto.Query.t()
defp books_of_user_query(%User{} = user) do
from [book: book] in Book.base_query(),
join: member in BookMember,
Expand Down
2 changes: 1 addition & 1 deletion apps/app/lib/app/books/book.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ defmodule App.Books.Book do
@type t :: %__MODULE__{
id: id(),
name: String.t(),
closed_at: NaiveDateTime.t(),
closed_at: NaiveDateTime.t() | nil,
deleted_at: NaiveDateTime.t(),
default_balance_params: TransferParams.t(),
inserted_at: NaiveDateTime.t(),
Expand Down
22 changes: 11 additions & 11 deletions apps/app/lib/app/books/book_member.ex
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ defmodule App.Books.BookMember do
@type id :: integer()

@type t :: %__MODULE__{
id: id(),
book_id: Book.id(),
book: Book.t(),
role: :creator | :member,
user_id: User.id() | nil,
user: User.t() | nil,
deleted_at: NaiveDateTime.t(),
nickname: String.t(),
id: id() | nil,
book_id: Book.id() | nil,
book: Book.t() | Ecto.Association.NotLoaded.t(),
role: :creator | :member | nil,
user_id: User.id() | Ecto.Association.NotLoaded.t() | nil,
user: User.t() | Ecto.Association.NotLoaded.t() | nil,
deleted_at: NaiveDateTime.t() | nil,
nickname: String.t() | nil,
display_name: String.t() | nil,
email: String.t() | nil,
balance_config: BalanceConfig.t() | nil,
balance_config_id: BalanceConfig.id() | nil,
balance_config: BalanceConfig.t() | Ecto.Association.NotLoaded.t() | nil,
balance: Money.t() | {:error, reasons :: [String.t()]} | nil,
inserted_at: NaiveDateTime.t(),
updated_at: NaiveDateTime.t()
inserted_at: NaiveDateTime.t() | nil,
updated_at: NaiveDateTime.t() | nil
}

schema "book_members" do
Expand Down
2 changes: 1 addition & 1 deletion apps/app/lib/app/books/members.ex
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ defmodule App.Books.Members do
@doc """
Link an existing book member to a user.
"""
@spec link_book_member_to_user(BookMember.t(), User.t()) :: BookMember.t()
@spec link_book_member_to_user(BookMember.t(), User.t()) :: :ok
def link_book_member_to_user(book_member, user) do
{:ok, _results} =
Ecto.Multi.new()
Expand Down

0 comments on commit cb68b23

Please sign in to comment.