From 9064d398439b1ea56463eb544d476cba2080b806 Mon Sep 17 00:00:00 2001 From: Antoine Bolvy Date: Thu, 17 Oct 2024 18:26:57 +0200 Subject: [PATCH] fix: credo issues and dialyxir warnings --- lib/hcaptcha/http.ex | 5 ++--- mix.exs | 2 +- test/hcaptcha_test.exs | 6 +++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/hcaptcha/http.ex b/lib/hcaptcha/http.ex index 9588cbb..89d9d6f 100644 --- a/lib/hcaptcha/http.ex +++ b/lib/hcaptcha/http.ex @@ -45,9 +45,8 @@ defmodule Hcaptcha.Http do result = with {:ok, response} <- - HTTPoison.post(url, body, @headers, timeout: timeout), - {:ok, data} <- @json_library.decode(response.body) do - {:ok, data} + HTTPoison.post(url, body, @headers, timeout: timeout) do + @json_library.decode(response.body) end case result do diff --git a/mix.exs b/mix.exs index 2bd3353..92f49ee 100644 --- a/mix.exs +++ b/mix.exs @@ -58,7 +58,7 @@ defmodule Hcaptcha.Mixfile do {:jason, "~> 1.4", optional: true}, {:credo, "~> 1.7.1", only: [:dev, :test], runtime: false}, {:ex_doc, "0.30.6", only: :dev}, - {:dialyxir, "~> 1.4.1", only: [:test]}, + {:dialyxir, "~> 1.4.1", only: [:test], runtime: false}, {:excoveralls, "~> 0.17.1", only: :test} ] end diff --git a/test/hcaptcha_test.exs b/test/hcaptcha_test.exs index c0f97a4..4bd9296 100644 --- a/test/hcaptcha_test.exs +++ b/test/hcaptcha_test.exs @@ -2,7 +2,7 @@ defmodule HcaptchaTest do use ExUnit.Case, async: true # see https://docs.hcaptcha.com/#integration-testing-test-keys - @hCaptcha_test_secret "0x0000000000000000000000000000000000000000" + @hcaptcha_test_secret "0x0000000000000000000000000000000000000000" test "When the supplied hcaptcha-response is invalid, errors are returned" do assert {:error, messages} = Hcaptcha.verify("not_valid") @@ -12,13 +12,13 @@ defmodule HcaptchaTest do test "When a valid response is supplied, a success response is returned" do assert {:ok, %{challenge_ts: _, hostname: _}} = Hcaptcha.verify("10000000-aaaa-bbbb-cccc-000000000001", - secret: @hCaptcha_test_secret + secret: @hcaptcha_test_secret ) end test "When an invalid response is supplied, an error response is returned" do assert {:error, [:invalid_input_response]} = - Hcaptcha.verify("invalid_response", secret: @hCaptcha_test_secret) + Hcaptcha.verify("invalid_response", secret: @hcaptcha_test_secret) end test "When secret is not overridden the configured secret is used" do