Skip to content

Commit 61da2e4

Browse files
authored
Merge pull request #35 from epochtalk/dialyxir-update
Dialyxir update, fixes static code analysis
2 parents 2116863 + ded5f90 commit 61da2e4

File tree

6 files changed

+34
-5
lines changed

6 files changed

+34
-5
lines changed

.github/workflows/main.yml

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,36 @@ jobs:
7777
key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-${{ hashFiles('mix.lock') }}
7878
- run: mix format --check-formatted
7979
- run: mix credo || ret=$?; if [ $ret != 2 ]; then exit $ret; fi
80-
- run: mix dialyzer --no-check --ignore-exit-status
80+
# PLT cache for dialyzer
81+
# Don't cache PLTs based on mix.lock hash, as Dialyzer can incrementally update even old ones
82+
# Cache key based on Elixir & Erlang version (also useful when running in matrix)
83+
- name: Restore PLT cache
84+
uses: actions/cache/restore@v3
85+
id: plt_cache
86+
with:
87+
key: |
88+
${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-plt
89+
restore-keys: |
90+
${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-plt
91+
path: |
92+
priv/plts
93+
# Create PLTs if no cache was found
94+
- name: Create PLTs
95+
if: steps.plt_cache.outputs.cache-hit != 'true'
96+
run: mix dialyzer --plt
97+
# By default, the GitHub Cache action will only save the cache if all steps in the job succeed,
98+
# so we separate the cache restore and save steps in case running dialyzer fails.
99+
- name: Save PLT cache
100+
uses: actions/cache/save@v3
101+
if: steps.plt_cache.outputs.cache-hit != 'true'
102+
id: plt_cache_save
103+
with:
104+
key: |
105+
${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-plt
106+
path: |
107+
priv/plts
108+
- name: Run dialyzer
109+
run: mix dialyzer --format github
81110
test_job:
82111
needs: dependencies
83112
name: Run tests

lib/epochtalk_server/models/role.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ defmodule EpochtalkServer.Models.Role do
168168
@doc """
169169
Updates the priority_restrictions of an existing `Role` in the database
170170
"""
171-
@spec set_priority_restrictions(id :: integer, priority_restrictions :: list()) ::
171+
@spec set_priority_restrictions(id :: integer, priority_restrictions :: list() | nil) ::
172172
{:ok, role :: t()} | {:error, Ecto.Changeset.t()}
173173
def set_priority_restrictions(id, []), do: set_priority_restrictions(id, nil)
174174

lib/epochtalk_server/session.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ defmodule EpochtalkServer.Session do
4646
Get the resource for a specified user_id and session_id if available
4747
Otherwise, return an error
4848
"""
49-
@spec get_resource(user_id :: String.t(), session_id :: String.t()) ::
49+
@spec get_resource(user_id :: non_neg_integer, session_id :: String.t()) ::
5050
{:ok, resource :: map()}
5151
| {:error, reason :: String.t() | Redix.Error.t() | Redix.ConnectionError.t()}
5252
def get_resource(user_id, session_id) do

lib/epochtalk_server_web/helpers/validate.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ defmodule EpochtalkServerWeb.Helpers.Validate do
1010
Helper used to default a list request parameter. If the list is valid, returns the list
1111
otherwise, defaults to empty list
1212
"""
13-
@spec sanitize_list(attrs :: map, key :: String.t()) :: List.t()
13+
@spec sanitize_list(attrs :: map, key :: String.t()) :: [any()] | []
1414
def sanitize_list(attrs, key)
1515
when is_map(attrs) and is_binary(key),
1616
do: if(is_list(attrs[key]), do: attrs[key], else: [])

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ defmodule EpochtalkServer.MixProject do
3636
{:argon2_elixir, "~> 3.0.0"},
3737
{:corsica, "~> 1.2.0"},
3838
{:credo, "~> 1.6", only: [:dev, :test], runtime: false},
39-
{:dialyxir, "~> 1.0", only: [:dev], runtime: false},
39+
{:dialyxir, "~> 1.2", only: [:dev], runtime: false},
4040
{:ecto_sql, "~> 3.6"},
4141
{:ex_doc, "~> 0.28.5"},
4242
{:gen_smtp, "~> 1.2"},

priv/plts/.keep

Whitespace-only changes.

0 commit comments

Comments
 (0)