From a080e89a35f7c0ec1f787c84082207c487ebaef8 Mon Sep 17 00:00:00 2001 From: Dan Barber Date: Mon, 19 Feb 2018 10:51:23 -0500 Subject: [PATCH 1/3] =?UTF-8?q?Unleash=20the=20Hound!=20=F0=9F=90=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .hound.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .hound.yml diff --git a/.hound.yml b/.hound.yml new file mode 100644 index 0000000..f283ada --- /dev/null +++ b/.hound.yml @@ -0,0 +1,2 @@ +credo: + enabled: true From e88545de0c9364bd2ed429b740496d881265c0b6 Mon Sep 17 00:00:00 2001 From: Dan Barber Date: Mon, 19 Feb 2018 11:16:00 -0500 Subject: [PATCH 2/3] Fix some Credo warnings --- lib/chess.ex | 2 ++ lib/chess/auth.ex | 9 +++++---- lib/chess/auth/guardian.ex | 2 ++ lib/chess/board.ex | 2 ++ lib/chess/store/game.ex | 2 ++ lib/chess_web/controllers/game_controller.ex | 10 ++++++---- 6 files changed, 19 insertions(+), 8 deletions(-) diff --git a/lib/chess.ex b/lib/chess.ex index 75097e7..923ec2f 100644 --- a/lib/chess.ex +++ b/lib/chess.ex @@ -1,4 +1,6 @@ defmodule Chess do + @moduledoc false + use Application # See http://elixir-lang.org/docs/stable/elixir/Application.html diff --git a/lib/chess/auth.ex b/lib/chess/auth.ex index 44a0c39..4b22712 100644 --- a/lib/chess/auth.ex +++ b/lib/chess/auth.ex @@ -105,10 +105,11 @@ defmodule Chess.Auth do @doc false def authenticate_user(username, password) do - Repo.one( - from u in User, - where: u.username == ^username - ) + query = from u in User, + where: u.username == ^username + + query + |> Repo.one |> Argon2.check_pass(password) end end diff --git a/lib/chess/auth/guardian.ex b/lib/chess/auth/guardian.ex index 7af60b8..5b4fef9 100644 --- a/lib/chess/auth/guardian.ex +++ b/lib/chess/auth/guardian.ex @@ -1,4 +1,6 @@ defmodule Chess.Auth.Guardian do + @moduledoc false + use Guardian, otp_app: :chess alias Chess.Auth diff --git a/lib/chess/board.ex b/lib/chess/board.ex index 341a453..b4c9faa 100644 --- a/lib/chess/board.ex +++ b/lib/chess/board.ex @@ -1,4 +1,6 @@ defmodule Chess.Board do + @moduledoc false + def output(board) do Enum.map(0..7, fn (rank) -> Enum.map(0..7, fn (file) -> diff --git a/lib/chess/store/game.ex b/lib/chess/store/game.ex index d3e66ac..6db4ba5 100644 --- a/lib/chess/store/game.ex +++ b/lib/chess/store/game.ex @@ -1,4 +1,6 @@ defmodule Chess.Store.Game do + @moduledoc false + use Ecto.Schema use Timex.Ecto.Timestamps diff --git a/lib/chess_web/controllers/game_controller.ex b/lib/chess_web/controllers/game_controller.ex index 4420783..d5bfb0a 100644 --- a/lib/chess_web/controllers/game_controller.ex +++ b/lib/chess_web/controllers/game_controller.ex @@ -5,10 +5,12 @@ defmodule ChessWeb.GameController do def index(conn, _params) do changeset = Game.changeset(%Game{}) - games = Game - |> Game.for_user(current_user(conn)) - |> Game.ordered - |> Repo.all + games = + Game + |> Game.for_user(current_user(conn)) + |> Game.ordered + |> Repo.all + render(conn, "index.html", games: games, changeset: changeset) end From 3c6cceabaa526f997ea2d4d943c5256372549bd4 Mon Sep 17 00:00:00 2001 From: Dan Barber Date: Mon, 19 Feb 2018 11:20:28 -0500 Subject: [PATCH 3/3] Small style fix --- lib/chess_web/controllers/game_controller.ex | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/chess_web/controllers/game_controller.ex b/lib/chess_web/controllers/game_controller.ex index d5bfb0a..b12519f 100644 --- a/lib/chess_web/controllers/game_controller.ex +++ b/lib/chess_web/controllers/game_controller.ex @@ -32,6 +32,7 @@ defmodule ChessWeb.GameController do def show(conn, %{"id" => id}) do game = Repo.get!(Game, id) + render(conn, "show.html", game: game) end