Skip to content

Commit a36a33d

Browse files
committed
Fix style violations reported by Credo.
1 parent a77c767 commit a36a33d

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

lib/ueberauth/strategy/twitter.ex

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@ defmodule Ueberauth.Strategy.Twitter do
55

66
use Ueberauth.Strategy, uid_field: :id_str
77

8-
alias Ueberauth.Auth.Info
98
alias Ueberauth.Auth.Credentials
109
alias Ueberauth.Auth.Extra
11-
alias Ueberauth.Strategy.Twitter
10+
alias Ueberauth.Auth.Info
11+
alias Ueberauth.Strategy.Twitter.OAuth
1212

1313
@doc """
1414
Handles initial request for Twitter authentication.
1515
"""
1616
def handle_request!(conn) do
1717
params = with_state_param([], conn)
18-
token = Twitter.OAuth.request_token!([], redirect_uri: callback_url(conn, params))
18+
token = OAuth.request_token!([], redirect_uri: callback_url(conn, params))
1919

2020
conn
2121
|> put_session(:twitter_token, token)
22-
|> redirect!(Twitter.OAuth.authorize_url!(token))
22+
|> redirect!(OAuth.authorize_url!(token))
2323
end
2424

2525
@doc """
@@ -28,7 +28,7 @@ defmodule Ueberauth.Strategy.Twitter do
2828
def handle_callback!(%Plug.Conn{params: %{"oauth_verifier" => oauth_verifier}} = conn) do
2929
token = get_session(conn, :twitter_token)
3030

31-
case Twitter.OAuth.access_token(token, oauth_verifier) do
31+
case OAuth.access_token(token, oauth_verifier) do
3232
{:ok, access_token} -> fetch_user(conn, access_token)
3333
{:error, error} -> set_errors!(conn, [error(error.code, error.reason)])
3434
end
@@ -104,7 +104,7 @@ defmodule Ueberauth.Strategy.Twitter do
104104
defp fetch_user(conn, token) do
105105
params = [{"include_entities", false}, {"skip_status", true}, {"include_email", true}]
106106

107-
case Twitter.OAuth.get("/1.1/account/verify_credentials.json", params, token) do
107+
case OAuth.get("/1.1/account/verify_credentials.json", params, token) do
108108
{:ok, %{status_code: 401, body: _, headers: _}} ->
109109
set_errors!(conn, [error("token", "unauthorized")])
110110

lib/ueberauth/strategy/twitter/internal.ex

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ defmodule Ueberauth.Strategy.Twitter.OAuth.Internal do
1717
|> OAuther.sign(url, extraparams, creds)
1818
|> OAuther.header()
1919

20-
HTTPoison.get(url, [header, {"Accept", "application/json"}], params: params)
20+
response = HTTPoison.get(url, [header, {"Accept", "application/json"}], params: params)
21+
22+
response
2123
|> decode_body()
2224
end
2325

@@ -42,13 +44,7 @@ defmodule Ueberauth.Strategy.Twitter.OAuth.Internal do
4244
def decode_body(other), do: other
4345

4446
def params_decode(resp) do
45-
resp
46-
|> String.split("&", trim: true)
47-
|> Enum.map(&String.split(&1, "="))
48-
|> Enum.map(&List.to_tuple/1)
49-
|> Enum.into(%{})
50-
51-
# |> Enum.reduce(%{}, fn({name, val}, acc) -> Map.put_new(acc, name, val) end)
47+
URI.decode_query(resp)
5248
end
5349

5450
def token(params) do

lib/ueberauth/strategy/twitter/oauth.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ defmodule Ueberauth.Strategy.Twitter.OAuth do
2424

2525
defexception [:message, :code]
2626

27-
def message(e = %{code: nil}), do: e.message
27+
def message(%{code: nil} = e), do: e.message
2828

2929
def message(e) do
3030
"#{e.message} (Code #{e.code})"

0 commit comments

Comments
 (0)