Skip to content

Commit 570ab50

Browse files
committed
Additional dialyzer related adjustments in rabbitmq_cli
1 parent 5d8ba2f commit 570ab50

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

deps/rabbitmq_cli/lib/rabbitmq/cli/auto_complete.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ defmodule RabbitMQ.CLI.AutoComplete do
1010
# Use the same jaro distance limit as in Elixir's "did you mean?"
1111
@jaro_distance_limit 0.77
1212

13+
@dialyzer :no_unused
14+
1315
@spec complete(String.t(), [String.t()]) :: [String.t()]
1416
def complete(_, []) do
1517
[]

deps/rabbitmq_cli/lib/rabbitmq/cli/core/parser.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ defmodule RabbitMQ.CLI.Core.Parser do
88
alias RabbitMQ.CLI.{CommandBehaviour, FormatterBehaviour}
99
alias RabbitMQ.CLI.Core.{CommandModules, Config, Helpers}
1010

11+
@dialyzer [:no_unused, :no_return]
12+
1113
def default_switches() do
1214
[
1315
node: :string,

deps/rabbitmq_cli/lib/rabbitmqctl.ex

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,20 @@ defmodule RabbitMQCtl do
1818
alias RabbitMQ.CLI.{CommandBehaviour, FormatterBehaviour}
1919
alias RabbitMQ.CLI.Ctl.Commands.HelpCommand
2020

21+
@dialyzer [
22+
{:no_unused, normalise_options: 1},
23+
{:no_unused, normalise_timeout: 1},
24+
{:nowarn_function, output_device: 1},
25+
{:nowarn_function, handle_shutdown: 1}
26+
]
27+
2128
# Enable unit tests for private functions
2229
@compile if Mix.env() == :test, do: :export_all
2330

2431
@type options() :: map()
2532
@type command_result() :: {:error, ExitCodes.exit_code(), term()} | term()
2633

27-
@spec main(list(string())) :: no_return()
28-
def main(["--auto-complete" | []]) do
29-
handle_shutdown(:ok)
30-
end
31-
34+
@spec main(list()) :: no_return()
3235
def main(unparsed_command) do
3336
exec_command(unparsed_command, &process_output/3)
3437
|> handle_shutdown
@@ -50,14 +53,13 @@ defmodule RabbitMQCtl do
5053
{:ok, ExitCodes.exit_ok(), Enum.join(HelpCommand.all_usage(parsed_options), "")}
5154
end
5255

53-
def exec_command(["--version"] = _unparsed_command, opts) do
56+
def exec_command(["--version"] = _unparsed_command, output_fun) do
5457
# rewrite `--version` as `version`
55-
exec_command(["version"], opts)
58+
exec_command(["version"], output_fun)
5659
end
5760

58-
def exec_command(["--auto-complete" | args], opts) do
59-
# rewrite `--auto-complete` as `autocomplete`
60-
exec_command(["autocomplete" | args], opts)
61+
def exec_command(["--auto-complete" | args], output_fun) do
62+
{:ok, ExitCodes.exit_ok(), ""}
6163
end
6264

6365
def exec_command(unparsed_command, output_fun) do
@@ -237,12 +239,7 @@ defmodule RabbitMQCtl do
237239
end
238240
end
239241

240-
@spec handle_shutdown(:ok) :: no_return()
241-
defp handle_shutdown(:ok) do
242-
exit_program(0)
243-
end
244-
245-
@spec handle_shutdown({:error, integer(), nil}) :: no_return()
242+
@spec handle_shutdown({:error, integer(), nil} | atom()) :: no_return()
246243
defp handle_shutdown({:error, exit_code, nil}) do
247244
exit_program(exit_code)
248245
end

0 commit comments

Comments
 (0)