Skip to content

Commit

Permalink
resolve dialyzer errors
Browse files Browse the repository at this point in the history
  • Loading branch information
the-mikedavis committed Jun 30, 2021
1 parent 964cab3 commit e859316
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
4 changes: 3 additions & 1 deletion .dialyzer_ignore.exs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[
~r"MACRO",
~r"lib/slipstream/socket_test.ex:\d+:pattern_match The pattern can never match the type nil | {atom(), atom()}.",
~r"lib/phoenix/router.ex"
~r"lib/phoenix/router.ex",
~r"lib/slipstream/connection/impl.ex",
~r"lib/slipstream/connection/pipeline.ex"
]
10 changes: 9 additions & 1 deletion lib/slipstream/connection/impl.ex
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ defmodule Slipstream.Connection.Impl do
{:ok, conn} <-
Mint.HTTP.stream_request_body(state.conn, state.request_ref, data) do
{:ok, %State{state | conn: conn, websocket: websocket}}
else
# coveralls-ignore-start
{:error, %Mint.WebSocket{} = websocket, reason} ->
{:error, put_in(state.websocket, websocket), reason}

{:error, conn, reason} ->
{:error, put_in(state.conn, conn), reason}
# coveralls-ignore-stop
end
end

Expand Down Expand Up @@ -128,7 +136,7 @@ defmodule Slipstream.Connection.Impl do

# this method of getting the path of a URI (including query) is maybe a bit
# unorthodox, but I think it's better than string manipulation
@spec path(URI.t()) :: charlist()
@spec path(URI.t()) :: String.t()
def path(%URI{} = uri) do
# select the v2 JSON serialization pattern
query = URI.decode_query(uri.query || "", %{"vsn" => "2.0.0"})
Expand Down
22 changes: 12 additions & 10 deletions lib/slipstream/connection/pipeline.ex
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ defmodule Slipstream.Connection.Pipeline do
{:cont, {:ok, put_in(state.websocket, websocket), acc ++ frames}}

# coveralls-ignore-start
{:error, reason} ->
{:halt, {:error, state, reason}}
{:error, websocket, reason} ->
{:halt, {:error, put_in(state.websocket, websocket), reason}}
end

_message, {:ok, state, acc} ->
Expand Down Expand Up @@ -166,12 +166,11 @@ defmodule Slipstream.Connection.Pipeline do
%{message: :connect, state: %{config: config} = state} = p
) do
with {:ok, conn} <- Impl.http_connect(config),
{_conn, {:ok, conn, ref}} <-
{conn, Impl.websocket_upgrade(conn, config)} do
{:ok, conn, ref} <- Impl.websocket_upgrade(conn, config) do
put_state(p, %State{state | conn: conn, request_ref: ref})
else
# coveralls-ignore-start
{conn, {:error, reason}} ->
{:error, conn, reason} ->
Mint.HTTP.close(conn)

p
Expand Down Expand Up @@ -229,7 +228,7 @@ defmodule Slipstream.Connection.Pipeline do

{:error, state, reason} ->
route_event state,
event(%Events.ChannelClosed{reason: {:send_failure, reason}})
%Events.ChannelClosed{reason: {:send_failure, reason}}

put_return(p, {:stop, :normal, state})
end
Expand Down Expand Up @@ -514,12 +513,15 @@ defmodule Slipstream.Connection.Pipeline do
{:ok, state} ->
put_state(p, state)

{:error, reason} ->
{:error, state, reason} ->
# coveralls-ignore-start
route_event p.state,
event(%Events.ChannelClosed{reason: {:send_failure, reason}})
route_event state,
%Events.ChannelClosed{reason: {:send_failure, reason}}

p
|> put_state(state)
|> put_return({:stop, :normal, state})

put_return(p, {:stop, :normal, p.state})
# coveralls-ignore-stop
end
end
Expand Down

0 comments on commit e859316

Please sign in to comment.