Skip to content

Commit

Permalink
Add a check whether default_ignore file is empty during execution and…
Browse files Browse the repository at this point in the history
… ignores it if is
  • Loading branch information
lnenad committed Sep 26, 2024
1 parent b69c5d8 commit c7234e7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
21 changes: 14 additions & 7 deletions lib/dialyxir/filter_map.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,21 @@ defmodule Dialyxir.FilterMap do
unused_filters_as_errors?: list_unused_filters? && !ignore_exit_status?
}

{ignore, _} =
ignore_file
|> File.read!()
|> Code.eval_string()
cond do
File.exists?(ignore_file) &&
match?(%{size: size} when size > 0, File.stat!(ignore_file)) ->
{ignore, _} =
ignore_file
|> File.read!()
|> Code.eval_string()

Enum.reduce(ignore, filter_map, fn skip, filter_map ->
put_in(filter_map.counters[skip], 0)
end)
Enum.reduce(ignore, filter_map, fn skip, filter_map ->
put_in(filter_map.counters[skip], 0)
end)

true ->
filter_map
end
end

@doc """
Expand Down
6 changes: 6 additions & 0 deletions lib/mix/tasks/dialyzer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,12 @@ defmodule Mix.Tasks.Dialyzer do
No :ignore_warnings opt specified in mix.exs. Using default: #{default}.
""")

ignore_warnings && File.exists?(ignore_warnings) &&
match?(%{size: size} when size == 0, File.stat!(default)) ->
info("""
:ignore_warnings opt specified in mix.exs: #{ignore_warnings}, but file is empty.
""")

ignore_warnings && File.exists?(ignore_warnings) ->
info("""
ignore_warnings: #{ignore_warnings}
Expand Down

0 comments on commit c7234e7

Please sign in to comment.