Skip to content

Commit

Permalink
fixed dialyzer option validation
Browse files Browse the repository at this point in the history
the code added in v0.21.2 wasn't executed
  • Loading branch information
lukaszsamson committed Jun 6, 2024
1 parent 37c7019 commit 223b195
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions apps/language_server/lib/language_server/server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1787,25 +1787,28 @@ defmodule ElixirLS.LanguageServer.Server do
else
IO.warn("Invalid `dialyzerWarnOpts` #{inspect(dialyzer_warn_opts)}")
end
end

all_warns =
ElixirLS.LanguageServer.Dialyzer.Analyzer.all_warns() |> Enum.map(&to_string/1)

for opt <- dialyzer_warn_opts, opt not in all_warns do
Logger.error("Invalid `dialyzerWarnOpts`: unknown warning option `#{opt}`")
try do
ElixirLS.LanguageServer.Dialyzer.Analyzer.matching_tags(
dialyzer_warn_opts
|> Enum.map(&String.to_atom/1)
)
catch
{:dialyzer_options_error, message} ->
Logger.error("Invalid `dialyzerWarnOpts`: #{message}")

JsonRpc.show_message(
:error,
"Invalid `dialyzerWarnOpts` in configuration. Unknown warning option `#{opt}`."
"Invalid `dialyzerWarnOpts` in configuration. #{message}."
)

unless :persistent_term.get(:language_server_test_mode, false) do
Process.sleep(2000)
System.halt(1)
else
IO.warn("Invalid `dialyzerWarnOpts`: unknown warning option `#{opt}`")
IO.warn("Invalid `dialyzerWarnOpts`: #{message}")
end
end
end

dialyzer_formats = [
Expand Down

0 comments on commit 223b195

Please sign in to comment.