Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix dialyzer warning from EctoJob.JobQueue.new function
__meta__ key was missing from return type declaration.
  • Loading branch information
mbuhot committed Apr 14, 2019
1 parent c4ebaa5 commit 42f2d28
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
10 changes: 9 additions & 1 deletion examples/ecto_job_demo/mix.exs
Expand Up @@ -8,6 +8,7 @@ defmodule EctoJobDemo.Mixfile do
elixir: "~> 1.5",
start_permanent: Mix.env() == :prod,
deps: deps(),
dialyzer: dialyzer(),
escript: [main_module: EctoJobDemo.CLI]
]
end
Expand All @@ -20,11 +21,18 @@ defmodule EctoJobDemo.Mixfile do
]
end

defp dialyzer do
[
flags: ["-Werror_handling", "-Wno_unused", "-Wunmatched_returns", "-Wunderspecs"]
]
end

# Run "mix help deps" to learn about dependencies.
defp deps do
[
{:ecto_job, path: "../../"},
{:exq, ">= 0.0.0"}
{:exq, ">= 0.0.0"},
{:dialyxir, "~> 1.0.0-rc.6", only: :dev, runtime: false}
]
end
end
2 changes: 2 additions & 0 deletions examples/ecto_job_demo/mix.lock
Expand Up @@ -2,9 +2,11 @@
"connection": {:hex, :connection, "1.0.4", "a1cae72211f0eef17705aaededacac3eb30e6625b04a6117c1b2db6ace7d5976", [:mix], [], "hexpm"},
"db_connection": {:hex, :db_connection, "2.0.3", "b4e8aa43c100e16f122ccd6798cd51c48c79fd391c39d411f42b3cd765daccb0", [:mix], [{:connection, "~> 1.0.2", [hex: :connection, repo: "hexpm", optional: false]}], "hexpm"},
"decimal": {:hex, :decimal, "1.6.0", "bfd84d90ff966e1f5d4370bdd3943432d8f65f07d3bab48001aebd7030590dcc", [:mix], [], "hexpm"},
"dialyxir": {:hex, :dialyxir, "1.0.0-rc.6", "78e97d9c0ff1b5521dd68041193891aebebce52fc3b93463c0a6806874557d7d", [:mix], [{:erlex, "~> 0.2.1", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm"},
"ecto": {:hex, :ecto, "3.0.6", "d33ab5b3f7553a41507d4b0ad5bf192d533119c4ad08f3a5d63d85aa12117dc9", [:mix], [{:decimal, "~> 1.6", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:poison, "~> 2.2 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: true]}], "hexpm"},
"ecto_sql": {:hex, :ecto_sql, "3.0.4", "e7a0feb0b2484b90981c56d5cd03c52122c1c31ded0b95ed213b7c5c07ae6737", [:mix], [{:db_connection, "~> 2.0", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.0.6", [hex: :ecto, repo: "hexpm", optional: false]}, {:mariaex, "~> 0.9.1", [hex: :mariaex, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.14.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.3.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm"},
"elixir_uuid": {:hex, :elixir_uuid, "1.2.0", "ff26e938f95830b1db152cb6e594d711c10c02c6391236900ddd070a6b01271d", [:mix], [], "hexpm"},
"erlex": {:hex, :erlex, "0.2.1", "cee02918660807cbba9a7229cae9b42d1c6143b768c781fa6cee1eaf03ad860b", [:mix], [], "hexpm"},
"exq": {:hex, :exq, "0.12.2", "7f4557a13a7fcfb159b318ee3275a1f2c38a572847d4cf8d47e303a15d0807b4", [:mix], [{:elixir_uuid, ">= 1.2.0", [hex: :elixir_uuid, repo: "hexpm", optional: false]}, {:poison, ">= 1.2.0 or ~> 2.0", [hex: :poison, repo: "hexpm", optional: false]}, {:redix, ">= 0.5.0 and < 0.8.0", [hex: :redix, repo: "hexpm", optional: false]}], "hexpm"},
"gen_stage": {:hex, :gen_stage, "0.14.1", "9d46723fda072d4f4bb31a102560013f7960f5d80ea44dcb96fd6304ed61e7a4", [:mix], [], "hexpm"},
"jason": {:hex, :jason, "1.1.2", "b03dedea67a99223a2eaf9f1264ce37154564de899fd3d8b9a21b1a6fd64afe7", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm"},
Expand Down
10 changes: 6 additions & 4 deletions lib/ecto_job/job_queue.ex
Expand Up @@ -45,11 +45,12 @@ defmodule EctoJob.JobQueue do
"""
@type job :: %{
__struct__: module,
__meta__: Ecto.Schema.Metadata.t(),
id: integer | nil,
state: state,
expires: DateTime.t() | nil,
schedule: DateTime.t() | nil,
attempt: integer(),
attempt: integer,
max_attempts: integer | nil,
params: map(),
notify: String.t() | nil,
Expand Down Expand Up @@ -189,10 +190,11 @@ defmodule EctoJob.JobQueue do
|> MyApp.Job.requeue("requeue_job", failed_job)
|> MyApp.Repo.transaction()
"""
@spec requeue(Multi.t(), term, EctoJob.JobQueue.job()) :: Multi.t() | {:error, :non_failed_job}
@spec requeue(Multi.t(), term, EctoJob.JobQueue.job()) ::
Multi.t() | {:error, :non_failed_job}
def requeue(multi, name, job = %__MODULE__{state: "FAILED"}) do
job_to_requeue = Changeset.change(job, %{state: "SCHEDULED", attempt: 0, expires: nil})
Multi.update(multi, name, job_to_requeue)
job_to_requeue = Changeset.change(job, %{state: "SCHEDULED", attempt: 0, expires: nil})
Multi.update(multi, name, job_to_requeue)
end

def requeue(_, _, _), do: {:error, :non_failed_job}
Expand Down
7 changes: 2 additions & 5 deletions mix.exs
Expand Up @@ -39,10 +39,7 @@ defmodule EctoJob.Mixfile do

defp dialyzer do
[
plt_add_apps: [:mix],
plt_add_deps: :apps_direct,
flags: ["-Werror_handling", "-Wno_unused", "-Wunmatched_returns", "-Wunderspecs"],
remove_defaults: [:unknown]
flags: ["-Werror_handling", "-Wno_unused", "-Wunmatched_returns", "-Wunderspecs"]
]
end

Expand All @@ -63,7 +60,7 @@ defmodule EctoJob.Mixfile do
{:jason, "~> 1.0"},
{:gen_stage, "~> 0.13"},
{:credo, "~> 1.0", only: :dev, runtime: false},
{:dialyxir, "~> 0.5", only: :dev, runtime: false},
{:dialyxir, "~> 1.0.0-rc.6", only: :dev, runtime: false},
{:ex_doc, "~> 0.12", only: :dev, runtime: false},
{:inch_ex, ">= 0.4.0", only: :dev, runtime: false}
]
Expand Down
3 changes: 2 additions & 1 deletion mix.lock
Expand Up @@ -4,10 +4,11 @@
"credo": {:hex, :credo, "1.0.0", "aaa40fdd0543a0cf8080e8c5949d8c25f0a24e4fc8c1d83d06c388f5e5e0ea42", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"},
"db_connection": {:hex, :db_connection, "2.0.3", "b4e8aa43c100e16f122ccd6798cd51c48c79fd391c39d411f42b3cd765daccb0", [:mix], [{:connection, "~> 1.0.2", [hex: :connection, repo: "hexpm", optional: false]}], "hexpm"},
"decimal": {:hex, :decimal, "1.6.0", "bfd84d90ff966e1f5d4370bdd3943432d8f65f07d3bab48001aebd7030590dcc", [:mix], [], "hexpm"},
"dialyxir": {:hex, :dialyxir, "0.5.1", "b331b091720fd93e878137add264bac4f644e1ddae07a70bf7062c7862c4b952", [:mix], [], "hexpm"},
"dialyxir": {:hex, :dialyxir, "1.0.0-rc.6", "78e97d9c0ff1b5521dd68041193891aebebce52fc3b93463c0a6806874557d7d", [:mix], [{:erlex, "~> 0.2.1", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm"},
"earmark": {:hex, :earmark, "1.3.1", "73812f447f7a42358d3ba79283cfa3075a7580a3a2ed457616d6517ac3738cb9", [:mix], [], "hexpm"},
"ecto": {:hex, :ecto, "3.0.6", "d33ab5b3f7553a41507d4b0ad5bf192d533119c4ad08f3a5d63d85aa12117dc9", [:mix], [{:decimal, "~> 1.6", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:poison, "~> 2.2 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: true]}], "hexpm"},
"ecto_sql": {:hex, :ecto_sql, "3.0.4", "e7a0feb0b2484b90981c56d5cd03c52122c1c31ded0b95ed213b7c5c07ae6737", [:mix], [{:db_connection, "~> 2.0", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.0.6", [hex: :ecto, repo: "hexpm", optional: false]}, {:mariaex, "~> 0.9.1", [hex: :mariaex, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.14.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.3.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm"},
"erlex": {:hex, :erlex, "0.2.1", "cee02918660807cbba9a7229cae9b42d1c6143b768c781fa6cee1eaf03ad860b", [:mix], [], "hexpm"},
"ex_doc": {:hex, :ex_doc, "0.19.2", "6f4081ccd9ed081b6dc0bd5af97a41e87f5554de469e7d76025fba535180565f", [:mix], [{:earmark, "~> 1.2", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.10", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm"},
"gen_stage": {:hex, :gen_stage, "0.14.1", "9d46723fda072d4f4bb31a102560013f7960f5d80ea44dcb96fd6304ed61e7a4", [:mix], [], "hexpm"},
"inch_ex": {:hex, :inch_ex, "1.0.1", "1f0af1a83cec8e56f6fc91738a09c838e858db3d78ef5f2ec040fe4d5a62dabf", [:mix], [{:poison, "~> 1.5 or ~> 2.0 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm"},
Expand Down

0 comments on commit 42f2d28

Please sign in to comment.