Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a check whether default_ignore file is empty during execution and ignores it if is #543

Merged
merged 1 commit into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading