dialyxir
dialyxir copied to clipboard
Inconsistent behaviour with missing "ignore warnings" file
Environment
- Elixir & Erlang/OTP versions (elixir --version):
Erlang/OTP 22 [erts-10.6.4] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]
Elixir 1.9.1 (compiled with Erlang/OTP 22)
- Which version of Dialyxir are you using? (cat mix.lock | grep dialyxir):
"dialyxir": {:hex, :dialyxir, "1.0.0", "6a1fa629f7881a9f5aaf3a78f094b2a51a0357c843871b8bc98824e7342d00a5", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "aeb06588145fac14ca08d8061a142d52753dbc2cf7f0d00fc1013f53f8654654"},
Current behavior
If you specify a non-existent file in the ignore_warnings
option, then Dialyxir will print a warning:
:ignore_warnings opt specified in mix.exs: .dialyzer_ignore, but file does not exist.
Then, the behaviour depends on whether there are any warnings in the code being analysed. If there are no warnings, Dialyxir exits successfully, but if there are warnings, Dialyxir fails with the following error message instead of printing the warnings:
** (File.Error) could not read file ".dialyzer_ignore": no such file or directory
(elixir) lib/file.ex:353: File.read!/1
lib/dialyxir/project.ex:132: Dialyxir.Project.filter_legacy_warnings/1
lib/dialyxir/formatter.ex:243: anonymous fn/2 in Dialyxir.Formatter.filter_legacy_warnings/2
(elixir) lib/enum.ex:3029: Enum.reject_list/2
lib/dialyxir/formatter.ex:26: Dialyxir.Formatter.format_and_filter/4
lib/dialyxir/dialyzer.ex:53: Dialyxir.Dialyzer.Runner.run/2
lib/dialyxir/dialyzer.ex:75: Dialyxir.Dialyzer.dialyze/3
lib/mix/tasks/dialyzer.ex:267: Mix.Tasks.Dialyzer.run_dialyzer/2
Expected behavior
I would expect the behaviour in face of a missing ignore file to be independent of whether there are any warnings, i.e. either make the warning about the missing file a fatal error in all cases, or print warnings without ignoring any of them.