Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dialyxir 1.1.0 support #583

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,19 @@ jobs:
keys:
- mix-cache-{{ checksum "mix.lock" }}

- restore_cache:
keys:
- dialyzer-cache-21.2-1.8.1

- run: mix do deps.get
- save_cache:
key: mix-cache-{{ checksum "mix.lock" }}
paths: "deps"

- run: mix format --check-formatted
- run: mix test
- run: mix dialyzer
- save_cache:
key: dialyzer-cache-21.2-1.8.1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know if it's possible to use the checksum here so that the cache is busted when the dependencies change? That way we don't have to manually update this when we update dependencies.

We could use the ".tool-versions" file, since that's the source of truth for Erlang and Elixir versions. So if that file changes, it means we should bust this cache.

What do you think? Would it be possible to do this?

- save_cache: 
    key: dialyzer-cache-{{ checksum ".tool-versions" }}

And the corresponding change in the -restore_cache entry?

paths: "priv/plts"
- run: MIX_ENV=prod mix compile
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
/.elixir_ls
erl_crash.dump
*.ez
/priv/plts/*.plt
/priv/plts/*.plt.hash
3 changes: 3 additions & 0 deletions dialyzer.ignore-warnings.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[
{"lib/bamboo/formatter.ex", :callback_type_mismatch, 73}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know what this warning was about and why we're ignoring it?

]
2 changes: 2 additions & 0 deletions lib/bamboo/api_error.ex
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ defmodule Bamboo.ApiError do

<extra_message>
"""
@spec raise_api_error(any()) :: no_return()
def raise_api_error(message), do: raise(__MODULE__, message: message)

@spec raise_api_error(String.t(), any(), Keyword.t()) :: no_return()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% sure that the third argument will always be a Keyword.t(). I imagine it can also be a map. Could we relax that to an Enum.t(), since that's a more relaxed version that includes both keyword lists and maps?

Suggested change
@spec raise_api_error(String.t(), any(), Keyword.t()) :: no_return()
@spec raise_api_error(String.t(), any(), Enum.t()) :: no_return()

def raise_api_error(service_name, response, params, extra_message \\ "") do
message = """
There was a problem sending the email through the #{service_name} API.
Expand Down
2 changes: 1 addition & 1 deletion lib/bamboo/email.ex
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ defmodule Bamboo.Email do
end
"""

@type address :: {String.t(), String.t()}
@type address :: {String.t() | nil, String.t()}
@type address_list :: nil | address | [address] | any

@type t :: %__MODULE__{
Expand Down
4 changes: 4 additions & 0 deletions lib/bamboo/mailer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ defmodule Bamboo.Mailer do
Email.welcome_email
|> Mailer.deliver_now(config: %{username: "Emma", smtp_port: 2525})
"""
@spec deliver_now(any()) :: no_return()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about changing the any() to Email.t() in all of these @spec definition changes? I think the first argument is supposed to be an email (even though I realize these functions only raise an error).

def deliver_now(_email, _opts \\ []) do
raise @cannot_call_directly_error
end
Expand All @@ -156,6 +157,7 @@ defmodule Bamboo.Mailer do

On failure, this function returns an error tuple: `{:error, error}`.
"""
@spec deliver_now!(any()) :: no_return()
def deliver_now!(_email, _opts \\ []) do
raise @cannot_call_directly_error
end
Expand All @@ -174,6 +176,7 @@ defmodule Bamboo.Mailer do

If the email is invalid, this function will return an `{:error, error}` tuple.
"""
@spec deliver_later(any()) :: no_return()
def deliver_later(_email, _opts \\ []) do
raise @cannot_call_directly_error
end
Expand All @@ -188,6 +191,7 @@ defmodule Bamboo.Mailer do

If the email is invalid, this function raises an error.
"""
@spec deliver_later!(any()) :: no_return()
def deliver_later!(_email, _opts \\ []) do
raise @cannot_call_directly_error
end
Expand Down
11 changes: 9 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ defmodule Bamboo.Mixfile do
package: package(),
docs: docs(),
deps: deps(),
xref: [exclude: [IEx]]
xref: [exclude: [IEx]],
dialyzer: [
plt_add_deps: :app_tree,
ignore_warnings: "dialyzer.ignore-warnings.exs",
plt_add_apps: [:mix, :ex_unit, :iex],
plt_file: {:no_warn, "priv/plts/dialyzer.plt"}
]
]
end

Expand Down Expand Up @@ -67,7 +73,8 @@ defmodule Bamboo.Mixfile do
{:floki, "~> 0.29", only: :test},
{:ex_doc, "~> 0.23", only: :dev},
{:hackney, ">= 1.15.2"},
{:jason, "~> 1.0", optional: true}
{:jason, "~> 1.0", optional: true},
{:dialyxir, "~> 1.0", only: [:test, :dev], runtime: false}
]
end
end
2 changes: 2 additions & 0 deletions mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
"certifi": {:hex, :certifi, "2.5.2", "b7cfeae9d2ed395695dd8201c57a2d019c0c43ecaf8b8bcb9320b40d6662f340", [:rebar3], [{:parse_trans, "~>3.3", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm", "3b3b5f36493004ac3455966991eaf6e768ce9884693d9968055aeeeb1e575040"},
"cowboy": {:hex, :cowboy, "1.1.2", "61ac29ea970389a88eca5a65601460162d370a70018afe6f949a29dca91f3bb0", [:rebar3], [{:cowlib, "~> 1.0.2", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "~> 1.3.2", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "f4763bbe08233eceed6f24bc4fcc8d71c17cfeafa6439157c57349aa1bb4f17c"},
"cowlib": {:hex, :cowlib, "1.0.2", "9d769a1d062c9c3ac753096f868ca121e2730b9a377de23dec0f7e08b1df84ee", [:make], [], "hexpm", "db622da03aa039e6366ab953e31186cc8190d32905e33788a1acb22744e6abd2"},
"dialyxir": {:hex, :dialyxir, "1.1.0", "c5aab0d6e71e5522e77beff7ba9e08f8e02bad90dfbeffae60eaf0cb47e29488", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "07ea8e49c45f15264ebe6d5b93799d4dd56a44036cf42d0ad9c960bc266c0b9a"},
"earmark": {:hex, :earmark, "1.3.2", "b840562ea3d67795ffbb5bd88940b1bed0ed9fa32834915125ea7d02e35888a5", [:mix], [], "hexpm", "e3be2bc3ae67781db529b80aa7e7c49904a988596e2dbff897425b48b3581161"},
"earmark_parser": {:hex, :earmark_parser, "1.4.10", "6603d7a603b9c18d3d20db69921527f82ef09990885ed7525003c7fe7dc86c56", [:mix], [], "hexpm", "8e2d5370b732385db2c9b22215c3f59c84ac7dda7ed7e544d7c459496ae519c0"},
"erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"},
"ex_doc": {:hex, :ex_doc, "0.23.0", "a069bc9b0bf8efe323ecde8c0d62afc13d308b1fa3d228b65bca5cf8703a529d", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm", "f5e2c4702468b2fd11b10d39416ddadd2fcdd173ba2a0285ebd92c39827a5a16"},
"ex_machina": {:hex, :ex_machina, "2.4.0", "09a34c5d371bfb5f78399029194a8ff67aff340ebe8ba19040181af35315eabb", [:mix], [{:ecto, "~> 2.2 or ~> 3.0", [hex: :ecto, repo: "hexpm", optional: true]}, {:ecto_sql, "~> 3.0", [hex: :ecto_sql, repo: "hexpm", optional: true]}], "hexpm", "a20bc9ddc721b33ea913b93666c5d0bdca5cbad7a67540784ae277228832d72c"},
"excoveralls": {:hex, :excoveralls, "0.13.2", "5ca05099750c086f144fcf75842c363fc15d7d9c6faa7ad323d010294ced685e", [:mix], [{:hackney, "~> 1.16", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "1e7ed75c158808a5a8f019d3ad63a5efe482994f2f8336c0a8c77d2f0ab152ce"},
Expand Down
Empty file added priv/plts/.gitkeep
Empty file.