Skip to content

Commit

Permalink
Fix dialyzer warnings and include in Travis CI
Browse files Browse the repository at this point in the history
  • Loading branch information
slashdotdash committed Nov 19, 2019
1 parent ac16ef7 commit 74fde76
Show file tree
Hide file tree
Showing 11 changed files with 88 additions and 17 deletions.
46 changes: 46 additions & 0 deletions .dialyzer_ignore.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[
{":0:unknown_function Function Commanded.Event.Upcaster.Atom.__impl__/1 does not exist.",
:unknown_function},
{":0:unknown_function Function Commanded.Event.Upcaster.BitString.__impl__/1 does not exist.",
:unknown_function},
{":0:unknown_function Function Commanded.Event.Upcaster.Float.__impl__/1 does not exist.",
:unknown_function},
{":0:unknown_function Function Commanded.Event.Upcaster.Function.__impl__/1 does not exist.",
:unknown_function},
{":0:unknown_function Function Commanded.Event.Upcaster.Integer.__impl__/1 does not exist.",
:unknown_function},
{":0:unknown_function Function Commanded.Event.Upcaster.List.__impl__/1 does not exist.",
:unknown_function},
{":0:unknown_function Function Commanded.Event.Upcaster.Map.__impl__/1 does not exist.",
:unknown_function},
{":0:unknown_function Function Commanded.Event.Upcaster.PID.__impl__/1 does not exist.",
:unknown_function},
{":0:unknown_function Function Commanded.Event.Upcaster.Port.__impl__/1 does not exist.",
:unknown_function},
{":0:unknown_function Function Commanded.Event.Upcaster.Reference.__impl__/1 does not exist.",
:unknown_function},
{":0:unknown_function Function Commanded.Event.Upcaster.Tuple.__impl__/1 does not exist.",
:unknown_function},
{":0:unknown_function Function Commanded.Serialization.JsonDecoder.Atom.__impl__/1 does not exist.",
:unknown_function},
{":0:unknown_function Function Commanded.Serialization.JsonDecoder.BitString.__impl__/1 does not exist.",
:unknown_function},
{":0:unknown_function Function Commanded.Serialization.JsonDecoder.Float.__impl__/1 does not exist.",
:unknown_function},
{":0:unknown_function Function Commanded.Serialization.JsonDecoder.Function.__impl__/1 does not exist.",
:unknown_function},
{":0:unknown_function Function Commanded.Serialization.JsonDecoder.Integer.__impl__/1 does not exist.",
:unknown_function},
{":0:unknown_function Function Commanded.Serialization.JsonDecoder.List.__impl__/1 does not exist.",
:unknown_function},
{":0:unknown_function Function Commanded.Serialization.JsonDecoder.Map.__impl__/1 does not exist.",
:unknown_function},
{":0:unknown_function Function Commanded.Serialization.JsonDecoder.PID.__impl__/1 does not exist.",
:unknown_function},
{":0:unknown_function Function Commanded.Serialization.JsonDecoder.Port.__impl__/1 does not exist.",
:unknown_function},
{":0:unknown_function Function Commanded.Serialization.JsonDecoder.Reference.__impl__/1 does not exist.",
:unknown_function},
{":0:unknown_function Function Commanded.Serialization.JsonDecoder.Tuple.__impl__/1 does not exist.",
:unknown_function}
]
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ erl_crash.dump
/doc
.DS_Store
.elixir_ls
/priv/plts/*.plt
/priv/plts/*.plt.hash
11 changes: 10 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
language: elixir

cache:
directories:
- priv/plts
- deps

elixir:
- 1.9.2
- 1.9.4

otp_release:
- 22.0

script:
- mix test
- travis_wait 30 mix dialyzer --halt-exit-status
6 changes: 3 additions & 3 deletions lib/commanded/event/mapper.ex
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ defmodule Commanded.Event.Mapper do
"""
def map_to_event_data(events, fields \\ [])

@spec map_to_event_data(list(event), map) :: list(EventData.t())
@spec map_to_event_data(list(event), Keyword.t()) :: list(EventData.t())
def map_to_event_data(events, fields) when is_list(events) do
Enum.map(events, &map_to_event_data(&1, fields))
end

@spec map_to_event_data(struct, map) :: EventData.t()
@spec map_to_event_data(struct, Keyword.t()) :: EventData.t()
def map_to_event_data(event, fields) do
%EventData{
causation_id: Keyword.get(fields, :causation_id),
Expand All @@ -63,7 +63,7 @@ defmodule Commanded.Event.Mapper do
@doc """
Map a list of `Commanded.EventStore.RecordedEvent` structs to their event data.
"""
@spec map_from_recorded_events(list(RecordedEvent.t())) :: event
@spec map_from_recorded_events(list(RecordedEvent.t())) :: [event]
def map_from_recorded_events(recorded_events) when is_list(recorded_events) do
Enum.map(recorded_events, &map_from_recorded_event/1)
end
Expand Down
3 changes: 2 additions & 1 deletion lib/commanded/event_store/adapter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ defmodule Commanded.EventStore.Adapter do
@doc """
Return a child spec defining all processes required by the event store.
"""
@callback child_spec(application, config) :: {:ok, [:supervisor.child_spec()], adapter_meta}
@callback child_spec(application, config) ::
{:ok, [:supervisor.child_spec() | {module, term} | module], adapter_meta}

@doc """
Append one or more events to a stream atomically.
Expand Down
1 change: 0 additions & 1 deletion lib/commanded/event_store/adapters/in_memory.ex
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,6 @@ defmodule Commanded.EventStore.Adapters.InMemory do
end)
end

defp catch_up(%Subscription{subscriber: nil}, _state), do: :ok
defp catch_up(%Subscription{start_from: :current}, _state), do: :ok

defp catch_up(%Subscription{stream_uuid: :all} = subscription, %State{} = state) do
Expand Down
2 changes: 1 addition & 1 deletion lib/commanded/pubsub/adapter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ defmodule Commanded.PubSub.Adapter do
Return an optional supervisor spec for pub/sub.
"""
@callback child_spec(application, config :: Keyword.t()) ::
{:ok, [:supervisor.child_spec()], adapter_meta}
{:ok, [:supervisor.child_spec() | {module, term} | module], adapter_meta}

@doc """
Subscribes the caller to the PubSub adapter's topic.
Expand Down
3 changes: 2 additions & 1 deletion lib/commanded/registration/adapter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ defmodule Commanded.Registration.Adapter do
@doc """
Return an optional supervisor spec for the registry
"""
@callback child_spec(application, config) :: {:ok, [:supervisor.child_spec()], adapter_meta}
@callback child_spec(application, config) ::
{:ok, [:supervisor.child_spec() | {module, term} | module], adapter_meta}

@doc """
Use to start a supervisor.
Expand Down
8 changes: 5 additions & 3 deletions lib/commanded/serialization/json_serializer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ if Code.ensure_loaded?(Jason) do
@doc """
Deserialize given JSON binary data to the expected type.
"""
def deserialize(binary, config \\ []) do
def deserialize(binary, config \\ [])

def deserialize(binary, config) do
{type, opts} =
case Keyword.get(config, :type) do
nil -> {nil, %{}}
type -> {TypeProvider.to_struct(type), %{keys: :atoms}}
nil -> {nil, []}
type -> {TypeProvider.to_struct(type), [keys: :atoms]}
end

binary
Expand Down
14 changes: 12 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ defmodule Commanded.Mixfile do
build_embedded: Mix.env() == :prod,
start_permanent: Mix.env() == :prod,
consolidate_protocols: Mix.env() == :prod,
dialyzer: dialyzer(),
name: "Commanded",
source_url: "https://github.com/commanded/commanded"
]
Expand Down Expand Up @@ -57,9 +58,9 @@ defmodule Commanded.Mixfile do
{:phoenix_pubsub, "~> 1.1", optional: true},

# Build and test tools
{:dialyxir, "~> 0.5", only: :dev, runtime: false},
{:dialyxir, "~> 1.0.0-rc.7", only: :dev, runtime: false},
{:ex_doc, "~> 0.21", only: :dev},
{:mix_test_watch, "~> 0.9", only: :dev},
{:mix_test_watch, "~> 1.0", only: :dev},
{:mox, "~> 0.5", only: :test}
]
end
Expand Down Expand Up @@ -211,4 +212,13 @@ defmodule Commanded.Mixfile do
defp aliases do
[]
end

defp dialyzer do
[
ignore_warnings: ".dialyzer_ignore.exs",
plt_add_apps: [:ex_unit, :jason, :mix, :phoenix_pubsub],
plt_add_deps: :app_tree,
plt_file: {:no_warn, "priv/plts/commanded.plt"}
]
end
end
9 changes: 5 additions & 4 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
%{
"dialyxir": {:hex, :dialyxir, "0.5.1", "b331b091720fd93e878137add264bac4f644e1ddae07a70bf7062c7862c4b952", [:mix], [], "hexpm"},
"dialyxir": {:hex, :dialyxir, "1.0.0-rc.7", "6287f8f2cb45df8584317a4be1075b8c9b8a69de8eeb82b4d9e6c761cf2664cd", [:mix], [{:erlex, ">= 0.2.5", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm"},
"earmark": {:hex, :earmark, "1.4.2", "3aa0bd23bc4c61cf2f1e5d752d1bb470560a6f8539974f767a38923bb20e1d7f", [:mix], [], "hexpm"},
"elixir_uuid": {:hex, :elixir_uuid, "1.2.0", "ff26e938f95830b1db152cb6e594d711c10c02c6391236900ddd070a6b01271d", [:mix], [], "hexpm"},
"elixir_uuid": {:hex, :elixir_uuid, "1.2.1", "dce506597acb7e6b0daeaff52ff6a9043f5919a4c3315abb4143f0b00378c097", [:mix], [], "hexpm"},
"erlex": {:hex, :erlex, "0.2.5", "e51132f2f472e13d606d808f0574508eeea2030d487fc002b46ad97e738b0510", [:mix], [], "hexpm"},
"ex_doc": {:hex, :ex_doc, "0.21.2", "caca5bc28ed7b3bdc0b662f8afe2bee1eedb5c3cf7b322feeeb7c6ebbde089d6", [:mix], [{:earmark, "~> 1.3.3 or ~> 1.4", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm"},
"file_system": {:hex, :file_system, "0.2.7", "e6f7f155970975789f26e77b8b8d8ab084c59844d8ecfaf58cbda31c494d14aa", [:mix], [], "hexpm"},
"jason": {:hex, :jason, "1.1.2", "b03dedea67a99223a2eaf9f1264ce37154564de899fd3d8b9a21b1a6fd64afe7", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm"},
"makeup": {:hex, :makeup, "1.0.0", "671df94cf5a594b739ce03b0d0316aa64312cee2574b6a44becb83cd90fb05dc", [:mix], [{:nimble_parsec, "~> 0.5.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm"},
"makeup_elixir": {:hex, :makeup_elixir, "0.14.0", "cf8b7c66ad1cff4c14679698d532f0b5d45a3968ffbcbfd590339cb57742f1ae", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm"},
"mix_test_watch": {:hex, :mix_test_watch, "0.9.0", "c72132a6071261893518fa08e121e911c9358713f62794a90c95db59042af375", [:mix], [{:file_system, "~> 0.2.1 or ~> 0.3", [hex: :file_system, repo: "hexpm", optional: false]}], "hexpm"},
"mix_test_watch": {:hex, :mix_test_watch, "1.0.2", "34900184cbbbc6b6ed616ed3a8ea9b791f9fd2088419352a6d3200525637f785", [:mix], [{:file_system, "~> 0.2.1 or ~> 0.3", [hex: :file_system, repo: "hexpm", optional: false]}], "hexpm"},
"mox": {:hex, :mox, "0.5.1", "f86bb36026aac1e6f924a4b6d024b05e9adbed5c63e8daa069bd66fb3292165b", [:mix], [], "hexpm"},
"nimble_parsec": {:hex, :nimble_parsec, "0.5.1", "c90796ecee0289dbb5ad16d3ad06f957b0cd1199769641c961cfe0b97db190e0", [:mix], [], "hexpm"},
"nimble_parsec": {:hex, :nimble_parsec, "0.5.2", "1d71150d5293d703a9c38d4329da57d3935faed2031d64bc19e77b654ef2d177", [:mix], [], "hexpm"},
"phoenix_pubsub": {:hex, :phoenix_pubsub, "1.1.2", "496c303bdf1b2e98a9d26e89af5bba3ab487ba3a3735f74bf1f4064d2a845a3e", [:mix], [], "hexpm"},
}

0 comments on commit 74fde76

Please sign in to comment.