Skip to content

Commit 6fa7d16

Browse files
committed
Fix dialyzer warnings
1 parent 513d110 commit 6fa7d16

File tree

7 files changed

+25
-18
lines changed

7 files changed

+25
-18
lines changed

lib/oauth2/client.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ defmodule OAuth2.Client do
2929
response = OAuth2.Client.post!(client, "/some/other/resources", %{foo: "bar"})
3030
"""
3131

32-
alias OAuth2.{AccessToken, Client, Error, Request}
32+
alias OAuth2.{AccessToken, Client, Error, Response, Request}
3333

3434
@type authorize_url :: binary
3535
@type body :: any

lib/oauth2/error.ex

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
defmodule OAuth2.Error do
2+
@moduledoc false
3+
4+
@type t :: %__MODULE__{
5+
reason: binary
6+
}
7+
28
defexception [:reason]
9+
310
def message(%__MODULE__{reason: :econnrefused}), do: "Connection refused"
411
def message(%__MODULE__{reason: reason}) when is_binary(reason), do: reason
512
def message(%__MODULE__{reason: reason}), do: inspect reason
613
end
7-

lib/oauth2/request.ex

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ defmodule OAuth2.Request do
1010
@doc """
1111
Makes a request of given type to the given URL using the `OAuth2.AccessToken`.
1212
"""
13-
@spec request(atom, Client.t, binary, body, Client.headers, Keyword.t) :: {:ok, Response.t} | {:error, Error.t}
13+
@spec request(atom, Client.t, binary, body, Client.headers, Keyword.t)
14+
:: {:ok, Response.t} | {:error, Response.t} | {:error, Error.t}
1415
def request(method, %Client{} = client, url, body, headers, opts) do
1516
url = client |> process_url(url) |> process_params(opts[:params])
1617
headers = req_headers(client, headers) |> Enum.uniq
@@ -38,12 +39,12 @@ defmodule OAuth2.Request do
3839
An `OAuth2.Error` exception is raised if the request results in an
3940
error tuple (`{:error, reason}`).
4041
"""
41-
@spec request!(atom, Client.t, binary, body, Client.headers, Keyword.t) :: Response.t | Error.t
42+
@spec request!(atom, Client.t, binary, body, Client.headers, Keyword.t) :: Response.t
4243
def request!(method, %Client{} = client, url, body, headers, opts) do
4344
case request(method, client, url, body, headers, opts) do
4445
{:ok, resp} ->
4546
resp
46-
{:error, %{status_code: code, headers: headers, body: body}} ->
47+
{:error, %Response{status_code: code, headers: headers, body: body}} ->
4748
raise %Error{reason: """
4849
Server responded with status: #{code}
4950

lib/oauth2/strategy.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ defmodule OAuth2.Strategy do
7878
|> merge_params(params)
7979
end
8080
"""
81-
@callback authorize_url(Client.t, OAuth2.params) :: Client.t
81+
@callback authorize_url(Client.t, Client.params) :: Client.t
8282

8383
@doc """
8484
Builds the URL to token endpoint.
@@ -96,7 +96,7 @@ defmodule OAuth2.Strategy do
9696
|> put_headers(headers)
9797
end
9898
"""
99-
@callback get_token(Client.t, OAuth2.params, OAuth2.headers) :: Client.t
99+
@callback get_token(Client.t, Client.params, Client.headers) :: Client.t
100100

101101
defmacro __using__(_) do
102102
quote do

mix.exs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defmodule OAuth2.Mixfile do
22
use Mix.Project
33

4-
@version "0.9.0"
4+
@version "0.9.1"
55

66
def project do
77
[app: :oauth2,
@@ -31,9 +31,9 @@ defmodule OAuth2.Mixfile do
3131

3232
# Test dependencies
3333
{:poison, "~> 3.0", only: :test},
34-
{:bypass, "~> 0.5", only: :test},
34+
{:bypass, "~> 0.6", only: :test},
3535
{:excoveralls, "~> 0.5", only: :test},
36-
{:dialyxir, "~> 0.4", only: [:dev], runtime: false},
36+
{:dialyxir, "~> 0.5", only: [:dev], runtime: false},
3737

3838
# Docs dependencies
3939
{:ex_doc, "~> 0.14", only: :dev}]

mix.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
%{"bypass": {:hex, :bypass, "0.5.1", "cf3e8a4d376ee1dcd89bf362dfaf1f4bf4a6e19895f52fdc2bafbd8207ce435f", [:mix], [{:cowboy, "~> 1.0", [hex: :cowboy, optional: false]}, {:plug, "~> 1.0", [hex: :plug, optional: false]}]},
1+
%{"bypass": {:hex, :bypass, "0.6.0", "fd0a8004fada4464e2ba98497755310b892a097f2fd975f4f787cf264066a335", [:mix], [{:cowboy, "~> 1.0", [hex: :cowboy, optional: false]}, {:plug, "~> 1.0", [hex: :plug, optional: false]}]},
22
"certifi": {:hex, :certifi, "1.0.0", "1c787a85b1855ba354f0b8920392c19aa1d06b0ee1362f9141279620a5be2039", [:rebar3], []},
3-
"cowboy": {:hex, :cowboy, "1.0.4", "a324a8df9f2316c833a470d918aaf73ae894278b8aa6226ce7a9bf699388f878", [:make, :rebar], [{:cowlib, "~> 1.0.0", [hex: :cowlib, optional: false]}, {:ranch, "~> 1.0", [hex: :ranch, optional: false]}]},
3+
"cowboy": {:hex, :cowboy, "1.1.2", "61ac29ea970389a88eca5a65601460162d370a70018afe6f949a29dca91f3bb0", [:rebar3], [{:cowlib, "~> 1.0.2", [hex: :cowlib, optional: false]}, {:ranch, "~> 1.3.2", [hex: :ranch, optional: false]}]},
44
"cowlib": {:hex, :cowlib, "1.0.2", "9d769a1d062c9c3ac753096f868ca121e2730b9a377de23dec0f7e08b1df84ee", [:make], []},
5-
"dialyxir": {:hex, :dialyxir, "0.4.4", "e93ff4affc5f9e78b70dc7bec7b07da44ae1ed3fef38e7113568dd30ad7b01d3", [:mix], []},
5+
"dialyxir": {:hex, :dialyxir, "0.5.0", "5bc543f9c28ecd51b99cc1a685a3c2a1a93216990347f259406a910cf048d1d7", [:mix], []},
66
"earmark": {:hex, :earmark, "1.1.0", "8c2bf85d725050a92042bc1edf362621004d43ca6241c756f39612084e95487f", [:mix], []},
77
"ex_doc": {:hex, :ex_doc, "0.14.5", "c0433c8117e948404d93ca69411dd575ec6be39b47802e81ca8d91017a0cf83c", [:mix], [{:earmark, "~> 1.0", [hex: :earmark, optional: false]}]},
88
"excoveralls": {:hex, :excoveralls, "0.6.1", "9e946b6db84dba592f47632157ecd135a46384b98a430fd16007dc910c70348b", [:mix], [{:exjsx, "~> 3.0", [hex: :exjsx, optional: false]}, {:hackney, ">= 0.12.0", [hex: :hackney, optional: false]}]},
@@ -11,9 +11,9 @@
1111
"idna": {:hex, :idna, "4.0.0", "10aaa9f79d0b12cf0def53038547855b91144f1bfcc0ec73494f38bb7b9c4961", [:rebar3], []},
1212
"jsx": {:hex, :jsx, "2.8.1", "1453b4eb3615acb3e2cd0a105d27e6761e2ed2e501ac0b390f5bbec497669846", [:mix, :rebar3], []},
1313
"metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], []},
14-
"mime": {:hex, :mime, "1.0.1", "05c393850524767d13a53627df71beeebb016205eb43bfbd92d14d24ec7a1b51", [:mix], []},
14+
"mime": {:hex, :mime, "1.1.0", "01c1d6f4083d8aa5c7b8c246ade95139620ef8effb009edde934e0ec3b28090a", [:mix], []},
1515
"mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], []},
16-
"plug": {:hex, :plug, "1.3.0", "6e2b01afc5db3fd011ca4a16efd9cb424528c157c30a44a0186bcc92c7b2e8f3", [:mix], [{:cowboy, "~> 1.0.1 or ~> 1.1", [hex: :cowboy, optional: true]}, {:mime, "~> 1.0", [hex: :mime, optional: false]}]},
16+
"plug": {:hex, :plug, "1.3.3", "d9be189924379b4e9d470caef87380d09549aea1ceafe6a0d41292c8c317c923", [:mix], [{:cowboy, "~> 1.0.1 or ~> 1.1", [hex: :cowboy, optional: true]}, {:mime, "~> 1.0", [hex: :mime, optional: false]}]},
1717
"poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], []},
18-
"ranch": {:hex, :ranch, "1.2.1", "a6fb992c10f2187b46ffd17ce398ddf8a54f691b81768f9ef5f461ea7e28c762", [:make], []},
18+
"ranch": {:hex, :ranch, "1.3.2", "e4965a144dc9fbe70e5c077c65e73c57165416a901bd02ea899cfd95aa890986", [:rebar3], []},
1919
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [:make, :rebar], []}}

test/oauth2/client_test.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ defmodule OAuth2.ClientTest do
3838
send_resp(conn, 200, ~s({"access_token":"test1234"}))
3939
end
4040

41-
assert {:ok, client} = Client.get_token(client, [code: "code1234"], [{"Accept", "application/json"}])
41+
assert {:ok, client} = Client.get_token(client, [code: "code1234"], [{"accept", "application/json"}])
4242
assert client.token.access_token == "test1234"
43-
assert %Client{} = Client.get_token!(client, [code: "code1234"], [{"Accept", "application/json"}])
43+
assert %Client{} = Client.get_token!(client, [code: "code1234"], [{"accept", "application/json"}])
4444
end
4545

4646
test "get_token, get_token! when `:token_method` is `:get`", %{client: client, server: server} do

0 commit comments

Comments
 (0)