From 07f24b329800644d870fec2d3bac2c46cac8b127 Mon Sep 17 00:00:00 2001 From: Jay Hayes Date: Fri, 10 Nov 2023 07:07:51 -0600 Subject: [PATCH] Fix results from $ mix credo suggest --all --strict --- lib/display.ex | 2 +- lib/koans.ex | 30 ++++++++++++------------------ lib/tracker.ex | 2 +- lib/watcher.ex | 2 +- 4 files changed, 15 insertions(+), 21 deletions(-) diff --git a/lib/display.ex b/lib/display.ex index 5a6710c8..0ad89863 100644 --- a/lib/display.ex +++ b/lib/display.ex @@ -3,7 +3,7 @@ defmodule Display do use GenServer alias IO.ANSI - alias Display.{ProgressBar, Intro, Failure, Notifications} + alias Display.{Failure, Intro, Notifications, ProgressBar} def start_link do GenServer.start_link(__MODULE__, %{clear_screen: true}, name: __MODULE__) diff --git a/lib/koans.ex b/lib/koans.ex index efb15042..d92a7218 100644 --- a/lib/koans.ex +++ b/lib/koans.ex @@ -19,12 +19,10 @@ defmodule Koans do generate_test_method(unquote(compiled_name), unquote(number_of_args), unquote(body)) def unquote(compiled_name)() do - try do - unquote(compiled_body) - :ok - rescue - e -> {:error, __STACKTRACE__, e} - end + unquote(compiled_body) + :ok + rescue + e -> {:error, __STACKTRACE__, e} end end end @@ -36,12 +34,10 @@ defmodule Koans do quote do def unquote(name)(answer) do - try do - unquote(single_var) - :ok - rescue - e -> {:error, __STACKTRACE__, e} - end + unquote(single_var) + :ok + rescue + e -> {:error, __STACKTRACE__, e} end end end @@ -54,12 +50,10 @@ defmodule Koans do quote do def unquote(name)({:multiple, unquote(answer_vars)}) do - try do - unquote(multi_var) - :ok - rescue - e -> {:error, __STACKTRACE__, e} - end + unquote(multi_var) + :ok + rescue + e -> {:error, __STACKTRACE__, e} end end end diff --git a/lib/tracker.ex b/lib/tracker.ex index 80f64c25..018dd83b 100644 --- a/lib/tracker.ex +++ b/lib/tracker.ex @@ -35,7 +35,7 @@ defmodule Tracker do end end - def wait_until_complete() do + def wait_until_complete do pid = Process.whereis(Tracker) receive do diff --git a/lib/watcher.ex b/lib/watcher.ex index 32ddaf69..eadb9a38 100644 --- a/lib/watcher.ex +++ b/lib/watcher.ex @@ -2,7 +2,7 @@ defmodule Watcher do @moduledoc false use GenServer - def start_link() do + def start_link do GenServer.start_link(__MODULE__, dirs: ["lib/koans"]) end