Skip to content

Commit

Permalink
Merge pull request #543 from lnenad/master
Browse files Browse the repository at this point in the history
Check & warn if exs ignore file is empty.
  • Loading branch information
jeremyjh authored Sep 28, 2024
2 parents b69c5d8 + c7234e7 commit 3768413
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 3768413

Please sign in to comment.