From dc1746346b8ab60754ba9e5a1b0787dd9e9285bb Mon Sep 17 00:00:00 2001 From: Diego Calero Date: Sun, 19 Mar 2023 15:37:05 -0300 Subject: [PATCH] Fixing dialyzer errors. --- .github/workflows/build.yml | 4 +++- .github/workflows/test.yml | 2 ++ lib/coophub/cache_warmer.ex | 4 ++-- lib/coophub/repos.ex | 2 +- lib/coophub_web/controllers/fallback_controller.ex | 10 ++++++---- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 12424a5..fb407ea 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -43,6 +43,8 @@ jobs: run: mix format --check-formatted - name: Run tests run: mix test + - name: Run dialyzer + run: mix dialyzer --check=true --compile=true - name: Build release run: | @@ -104,7 +106,7 @@ jobs: - name: Commit VERSION file run: | git add VERSION - git config --local user.name "coophub-ci" + git config --local user.name "fiqus-ci" git config --local user.email "ci@fiqus.coop" git commit -m "Bump to $RELEASE_TAG" - name: Push VERSION file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c5c516e..177ebee 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,3 +21,5 @@ jobs: run: mix format --check-formatted - name: Run tests run: mix test + - name: Run dialyzer + run: mix dialyzer --check=true --compile=true diff --git a/lib/coophub/cache_warmer.ex b/lib/coophub/cache_warmer.ex index a69d81f..81274b7 100644 --- a/lib/coophub/cache_warmer.ex +++ b/lib/coophub/cache_warmer.ex @@ -21,7 +21,7 @@ defmodule Coophub.CacheWarmer do @doc """ Executes this cache warmer. """ - @spec execute(any) :: :ignore | {:ok, list({atom, Repos.org()}), keyword} + @spec execute(any) :: :ignore | {:ok, list({binary, Repos.org()}), keyword} def execute(_state) do ## Delay the execution a bit to ensure Cachex is available Process.sleep(2000) @@ -194,7 +194,7 @@ defmodule Coophub.CacheWarmer do defp get_org(key, %{"source" => source} = yml_data) do case Backends.get_org(source, key, yml_data) do %Organization{} = org -> - %Organization{org | cached_at: DateTime.utc_now()} + %Organization{org | cached_at: DateTime.utc_now() |> DateTime.to_iso8601()} error -> Logger.error("Couldn't get org data: #{inspect(error)}") diff --git a/lib/coophub/repos.ex b/lib/coophub/repos.ex index 9e44fb4..a7a03bc 100644 --- a/lib/coophub/repos.ex +++ b/lib/coophub/repos.ex @@ -30,7 +30,7 @@ defmodule Coophub.Repos do Orgs is a list of org maps """ @type orgs :: list(org()) | [] - @type orgs_map :: %{required(String.t()) => org()} + @type orgs_map :: %{required(binary) => org()} @spec get_all_orgs :: orgs_map() | :error def get_all_orgs() do diff --git a/lib/coophub_web/controllers/fallback_controller.ex b/lib/coophub_web/controllers/fallback_controller.ex index 448351f..e7a43c3 100644 --- a/lib/coophub_web/controllers/fallback_controller.ex +++ b/lib/coophub_web/controllers/fallback_controller.ex @@ -9,12 +9,14 @@ defmodule CoophubWeb.FallbackController do def call(conn, {:error, :not_found}) do conn |> put_status(:not_found) - |> render(CoophubWeb.ErrorView, :"404") + |> put_view(CoophubWeb.ErrorView) + |> render(:"404") end - def call(conn, {:error, _}) do + def call(conn, _error) do conn - |> put_status(:unprocessable_entity) - |> render(CoophubWeb.ChangesetView, "error.json") + |> put_status(:internal_server_error) + |> put_view(CoophubWeb.ErrorView) + |> render(:"500") end end