• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

scrogson / oauth2 / 152
96%

Build:
DEFAULT BRANCH: master
Ran 30 Dec 2016 07:44PM UTC
Jobs 2
Files 14
Run time 23s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

pending completion
152

push

travis-ci

scrogson
Fix dialyzer warning on @type params (#84)

Dialyzer complains about the `get_token/4` and `get_token!/4` functions, because the typespec says that the `params` argument is supposed to be a map with binary keys, whereas `OAuth2.Strategy.AuthCode.get_token/3` expects them to be a Keyword list.

Code:

```elixir
client()
|> OAuth2.Client.get_token!([code: code], [], [])
|> OAuth2.Client.get!("/user")
```

Dialyzer's complaint:

```
git_hub.ex:60: The call 'Elixir.OAuth2.Client':'get_token!'(#{'__struct__':='Elixir.OAuth2.Client', 'authorize_url':=binary(), 'client_id':=binary(), 'client_secret':=binary(), 'headers':=[{binary(),binary()}], 'params':=#{binary()=>binary() | [binary() | [any()] | map()] | #{binary()=>binary() | [any()] | map()}}, 'redirect_uri':=binary(), 'site':=binary(), 'strategy':=atom(), 'token':='nil' | #{'__struct__':='Elixir.OAuth2.AccessToken', 'access_token':=binary(), 'expires_at':=integer(), 'other_params':=#{}, 'refresh_token':=binary(), 'token_type':=binary()}, 'token_method':=atom(), 'token_url':=binary()},[{'code',_},...],[],[]) will never return since the success typing is (#{'__struct__':='Elixir.OAuth2.Client', 'authorize_url':=binary(), 'client_id':=binary(), 'client_secret':=binary(), 'headers':=[{binary(),binary()}], 'params':=#{binary()=>binary() | [binary() | [any()] | map()] | #{binary()=>binary() | [any()] | map()}}, 'redirect_uri':=binary(), 'site':=binary(), 'strategy':=atom(), 'token':='nil' | #{'__struct__':='Elixir.OAuth2.AccessToken', 'access_token':=binary(), 'expires_at':=integer(), 'other_params':=#{}, 'refresh_token':=binary(), 'token_type':=binary()}, 'token_method':=atom(), 'token_url':=binary()},#{binary()=>binary() | [binary() | [any()] | #{binary()=>_}] | #{binary()=>binary() | [any()] | #{binary()=>_}}},[{binary(),binary()}],[{atom(),_}]) -> #{'__struct__':='Elixir.OAuth2.Client', 'authorize_url':=binary(), 'client_id':=binary(), 'client_secret':=binary(), 'headers':=[], 'params':=#{}, 'redirect_uri':=binary(), 'site':=binary(), 'strategy':=atom(), 'token':=#{'__struct__':='Elixir.OAuth2.AccessToken', 'access_token':=binary(), 'expires_at':=integer(), 'other_params':=#{}, 'refresh_token':=binary(), 'token_type':=binary()}, 'token_method':=atom(), 'token_url':=binary()} and the contract is (t(),params(),headers(),'Elixir.Keyword':t()) -> 'Elixir.OAuth2.Client':t() | 'Elixir.OAuth2.Error':t()
```

If I change the code to make Dialyzer happy, it no longer functions:

```elixir
client()
|> OAuth2.Client.get_token!(%{"code" => code}, [], [])
|> OAuth2.Client.get!("/user")
```

However, with this typespec change, everything works fine.

166 of 179 relevant lines covered (92.74%)

20.27 hits per line

Jobs
ID Job ID Ran Files Coverage
1 152.1 30 Dec 2016 07:44PM UTC 0
91.06
Travis Job 152.1
3 152.3 30 Dec 2016 07:44PM UTC 0
92.18
Travis Job 152.3
Source Files on build 152
Detailed source file information is not available for this build.
  • Back to Repo
  • Travis Build #152
  • 75c397e2 on github
  • Prev Build on master (#150)
  • Next Build on master (#154)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc