summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRin Kuryloski <kuryloskip@vmware.com>2023-01-31 15:05:52 +0100
committerGitHub <noreply@github.com>2023-01-31 15:05:52 +0100
commitbdb2046185373069ac8da05a1611cf7138295b9f (patch)
treea0293e3e00da4b1c2975ce7b71796e023fd5a559
parentb02c268632e7729f7ce809adb264e05a8d041084 (diff)
downloadrabbitmq-server-git-bdb2046185373069ac8da05a1611cf7138295b9f.tar.gz
Add rabbitmq_cli dialyze to bazel (#7066)
* Add rabbitmq_cli dialyze to bazel and fix a number of warnings Because we stop mix from recompiling rabbit_common in bazel, many unknown functions are reported, so this dialyzer analysis is somewhat incomplete. * Use erlang dialyzer for rabbitmq_cli rather than mix dialyzer Since this resolves all of the rabbit functions, there are far fewer unknown functions. Requires yet to be released rules_erlang 3.9.2 * Temporarily use pre-release rules_erlang So that checks can run on this PR without a release * Fix additional dialyzer warnings in rabbitmq_cli * rabbitmq_cli: mix format * Additional fixes for ignored return values * Revert "Temporarily use pre-release rules_erlang" This reverts commit c16b5b6815abd7e323fc28aa3ce8c8af255b70e5. * Use rules_erlang 3.9.2
-rw-r--r--MODULE.bazel2
-rw-r--r--WORKSPACE2
-rw-r--r--deps/rabbit_common/src/rabbit_misc.erl2
-rw-r--r--deps/rabbitmq_cli/BUILD.bazel19
-rw-r--r--deps/rabbitmq_cli/lib/rabbitmq/cli/command_behaviour.ex2
-rw-r--r--deps/rabbitmq_cli/lib/rabbitmq/cli/core/code_path.ex6
-rw-r--r--deps/rabbitmq_cli/lib/rabbitmq/cli/core/command_modules.ex2
-rw-r--r--deps/rabbitmq_cli/lib/rabbitmq/cli/core/helpers.ex2
-rw-r--r--deps/rabbitmq_cli/lib/rabbitmq/cli/core/input.ex2
-rw-r--r--deps/rabbitmq_cli/lib/rabbitmq/cli/core/memory.ex2
-rw-r--r--deps/rabbitmq_cli/lib/rabbitmq/cli/core/networking.ex2
-rw-r--r--deps/rabbitmq_cli/lib/rabbitmq/cli/core/parser.ex15
-rw-r--r--deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/exec_command.ex2
-rw-r--r--deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/export_definitions_command.ex4
-rw-r--r--deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/forget_cluster_node_command.ex2
-rw-r--r--deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/help_command.ex4
-rw-r--r--deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/import_definitions_command.ex4
-rw-r--r--deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/list_channels_command.ex2
-rw-r--r--deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/wait_command.ex5
-rw-r--r--deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/info_keys.ex2
-rw-r--r--deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/rpc_stream.ex5
-rw-r--r--deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/erlang_cookie_sources_command.ex2
-rw-r--r--deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/observer_command.ex1
-rw-r--r--deps/rabbitmq_cli/lib/rabbitmq/cli/formatters/report.ex1
-rw-r--r--deps/rabbitmq_cli/lib/rabbitmq/cli/formatters/string_per_line.ex2
-rw-r--r--deps/rabbitmq_cli/lib/rabbitmq/cli/plugins/plugins_helpers.ex4
-rw-r--r--deps/rabbitmq_cli/lib/rabbitmq/cli/queues/commands/peek_command.ex1
-rw-r--r--deps/rabbitmq_cli/lib/rabbitmqctl.ex11
-rw-r--r--deps/rabbitmq_cli/rabbitmqctl.bzl20
-rw-r--r--deps/rabbitmq_cli/rabbitmqctl_test.bzl3
30 files changed, 86 insertions, 47 deletions
diff --git a/MODULE.bazel b/MODULE.bazel
index 450f0b7742..71bab0e3eb 100644
--- a/MODULE.bazel
+++ b/MODULE.bazel
@@ -31,7 +31,7 @@ bazel_dep(
bazel_dep(
name = "rules_erlang",
- version = "3.9.1",
+ version = "3.9.2",
)
erlang_config = use_extension(
diff --git a/WORKSPACE b/WORKSPACE
index 26390588d7..356b91f0a2 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -4,7 +4,7 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository", "new_git_r
git_repository(
name = "rules_erlang",
remote = "https://github.com/rabbitmq/rules_erlang.git",
- tag = "3.9.1",
+ tag = "3.9.2",
)
load("@rules_erlang//:internal_deps.bzl", "rules_erlang_internal_deps")
diff --git a/deps/rabbit_common/src/rabbit_misc.erl b/deps/rabbit_common/src/rabbit_misc.erl
index b211d1efb7..4c66987101 100644
--- a/deps/rabbit_common/src/rabbit_misc.erl
+++ b/deps/rabbit_common/src/rabbit_misc.erl
@@ -232,7 +232,7 @@
-spec pset(term(), term(), [term()]) -> [term()].
-spec format_message_queue(any(), priority_queue:q()) -> term().
-spec os_cmd(string()) -> string().
--spec is_os_process_alive(non_neg_integer()) -> boolean().
+-spec is_os_process_alive(non_neg_integer() | string()) -> boolean().
-spec version() -> string().
-spec otp_release() -> string().
-spec otp_system_version() -> string().
diff --git a/deps/rabbitmq_cli/BUILD.bazel b/deps/rabbitmq_cli/BUILD.bazel
index 1aff961699..32f7006b01 100644
--- a/deps/rabbitmq_cli/BUILD.bazel
+++ b/deps/rabbitmq_cli/BUILD.bazel
@@ -1,10 +1,11 @@
load("@bazel_skylib//rules:select_file.bzl", "select_file")
+load("@rules_erlang//:dialyze.bzl", "dialyze", "plt")
load(":rabbitmqctl.bzl", "rabbitmqctl")
load(":rabbitmqctl_check_formatted.bzl", "rabbitmqctl_check_formatted_test")
load(":rabbitmqctl_test.bzl", "rabbitmqctl_test")
load("//:rabbitmq_home.bzl", "rabbitmq_home")
load("//:rabbitmq_run.bzl", "rabbitmq_run")
-load("//:rabbitmq.bzl", "STARTS_BACKGROUND_BROKER_TAG")
+load("//:rabbitmq.bzl", "RABBITMQ_DIALYZER_OPTS", "STARTS_BACKGROUND_BROKER_TAG")
# Note: All the various rabbitmq-* scripts are just copies of rabbitmqctl
rabbitmqctl(
@@ -71,6 +72,22 @@ test_suite(
tests = ["check_formatted"],
)
+plt(
+ name = "deps_plt",
+ libs = [":elixir"],
+ deps = [
+ ":elixir",
+ "//deps/rabbit:erlang_app",
+ "//deps/rabbit_common:erlang_app",
+ ],
+)
+
+dialyze(
+ dialyzer_opts = RABBITMQ_DIALYZER_OPTS,
+ libs = [":elixir"],
+ plt = ":deps_plt",
+)
+
rabbitmqctl_test(
name = "tests",
size = "large",
diff --git a/deps/rabbitmq_cli/lib/rabbitmq/cli/command_behaviour.ex b/deps/rabbitmq_cli/lib/rabbitmq/cli/command_behaviour.ex
index 9d77e9a987..baa328519f 100644
--- a/deps/rabbitmq_cli/lib/rabbitmq/cli/command_behaviour.ex
+++ b/deps/rabbitmq_cli/lib/rabbitmq/cli/command_behaviour.ex
@@ -47,7 +47,7 @@ defmodule RabbitMQ.CLI.CommandBehaviour do
@callback printer() :: atom()
@callback scopes() :: [atom()] | nil
@callback description() :: String.t()
- @callback help_section() :: String.t() | {:plugin, atom()}
+ @callback help_section() :: String.t() | atom() | {:plugin, atom()}
@callback usage_additional() ::
String.t()
| [String.t()]
diff --git a/deps/rabbitmq_cli/lib/rabbitmq/cli/core/code_path.ex b/deps/rabbitmq_cli/lib/rabbitmq/cli/core/code_path.ex
index 57cbb82790..8e382bf8ce 100644
--- a/deps/rabbitmq_cli/lib/rabbitmq/cli/core/code_path.ex
+++ b/deps/rabbitmq_cli/lib/rabbitmq/cli/core/code_path.ex
@@ -15,7 +15,7 @@ defmodule RabbitMQ.CLI.Core.CodePath do
val ->
with {:ok, plugins_dir} <- val do
String.split(to_string(plugins_dir), Platform.path_separator())
- |> Enum.map(&add_directory_plugins_to_load_path/1)
+ |> Enum.each(&add_directory_plugins_to_load_path/1)
:ok
end
@@ -99,11 +99,11 @@ defmodule RabbitMQ.CLI.Core.CodePath do
_ ->
case Application.load(:rabbit) do
:ok ->
- Code.ensure_loaded(:rabbit_plugins)
+ _ = Code.ensure_loaded(:rabbit_plugins)
:ok
{:error, {:already_loaded, :rabbit}} ->
- Code.ensure_loaded(:rabbit_plugins)
+ _ = Code.ensure_loaded(:rabbit_plugins)
:ok
{:error, err} ->
diff --git a/deps/rabbitmq_cli/lib/rabbitmq/cli/core/command_modules.ex b/deps/rabbitmq_cli/lib/rabbitmq/cli/core/command_modules.ex
index 002d1cda29..8e7f916ab0 100644
--- a/deps/rabbitmq_cli/lib/rabbitmq/cli/core/command_modules.ex
+++ b/deps/rabbitmq_cli/lib/rabbitmq/cli/core/command_modules.ex
@@ -59,7 +59,7 @@ defmodule RabbitMQ.CLI.Core.CommandModules do
end
def plugin_modules(opts) do
- require_rabbit(opts)
+ _ = require_rabbit(opts)
enabled_plugins =
try do
diff --git a/deps/rabbitmq_cli/lib/rabbitmq/cli/core/helpers.ex b/deps/rabbitmq_cli/lib/rabbitmq/cli/core/helpers.ex
index 0056fd584d..80ab3fe1d1 100644
--- a/deps/rabbitmq_cli/lib/rabbitmq/cli/core/helpers.ex
+++ b/deps/rabbitmq_cli/lib/rabbitmq/cli/core/helpers.ex
@@ -130,7 +130,7 @@ defmodule RabbitMQ.CLI.Core.Helpers do
end
def apply_if_exported(mod, fun, args, default) do
- Code.ensure_loaded(mod)
+ _ = Code.ensure_loaded(mod)
case function_exported?(mod, fun, length(args)) do
true -> apply(mod, fun, args)
diff --git a/deps/rabbitmq_cli/lib/rabbitmq/cli/core/input.ex b/deps/rabbitmq_cli/lib/rabbitmq/cli/core/input.ex
index 23ce23f612..7126b8fbf4 100644
--- a/deps/rabbitmq_cli/lib/rabbitmq/cli/core/input.ex
+++ b/deps/rabbitmq_cli/lib/rabbitmq/cli/core/input.ex
@@ -26,7 +26,7 @@ defmodule RabbitMQ.CLI.Core.Input do
end
def consume_multiline_string() do
- val = IO.read(:stdio, :all)
+ val = IO.read(:stdio, :eof)
case val do
:eof -> :eof
diff --git a/deps/rabbitmq_cli/lib/rabbitmq/cli/core/memory.ex b/deps/rabbitmq_cli/lib/rabbitmq/cli/core/memory.ex
index eb64b6c9e5..ed5189816b 100644
--- a/deps/rabbitmq_cli/lib/rabbitmq/cli/core/memory.ex
+++ b/deps/rabbitmq_cli/lib/rabbitmq/cli/core/memory.ex
@@ -90,7 +90,7 @@ defmodule RabbitMQ.CLI.Core.Memory do
end
def parse_watermark(n) when is_bitstring(n) do
- case IU.parse(n) do
+ case IU.parse(to_charlist(n)) do
{:ok, parsed} -> parsed
err -> err
end
diff --git a/deps/rabbitmq_cli/lib/rabbitmq/cli/core/networking.ex b/deps/rabbitmq_cli/lib/rabbitmq/cli/core/networking.ex
index ac3babf2bb..690f2f7f07 100644
--- a/deps/rabbitmq_cli/lib/rabbitmq/cli/core/networking.ex
+++ b/deps/rabbitmq_cli/lib/rabbitmq/cli/core/networking.ex
@@ -22,7 +22,7 @@ defmodule RabbitMQ.CLI.Core.Networking do
end
end
- @spec address_family(String.t() | atom()) :: boolean()
+ @spec valid_address_family?(String.t() | atom()) :: boolean()
def valid_address_family?(value) when is_atom(value) do
valid_address_family?(to_string(value))
end
diff --git a/deps/rabbitmq_cli/lib/rabbitmq/cli/core/parser.ex b/deps/rabbitmq_cli/lib/rabbitmq/cli/core/parser.ex
index e5a5da5a90..d734a5c037 100644
--- a/deps/rabbitmq_cli/lib/rabbitmq/cli/core/parser.ex
+++ b/deps/rabbitmq_cli/lib/rabbitmq/cli/core/parser.ex
@@ -98,13 +98,13 @@ defmodule RabbitMQ.CLI.Core.Parser do
## This is an optimisation for pluggable command discovery.
## Most of the time a command will be from rabbitmqctl application
## so there is not point in scanning plugins for potential commands
- CommandModules.load_core(options)
+ _ = CommandModules.load_core(options)
core_commands = CommandModules.module_map_core()
command =
case core_commands[cmd_name] do
nil ->
- CommandModules.load(options)
+ _ = CommandModules.load(options)
module_map = CommandModules.module_map()
module_map[cmd_name] ||
@@ -242,11 +242,12 @@ defmodule RabbitMQ.CLI.Core.Parser do
end
defp assert_no_conflict(command, command_fields, formatter_fields, err) do
- merge_if_different(
- formatter_fields,
- command_fields,
- {:command_invalid, {command, {err, formatter_fields, command_fields}}}
- )
+ _ =
+ merge_if_different(
+ formatter_fields,
+ command_fields,
+ {:command_invalid, {command, {err, formatter_fields, command_fields}}}
+ )
:ok
end
diff --git a/deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/exec_command.ex b/deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/exec_command.ex
index 5d3e6eb1d8..8184797a35 100644
--- a/deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/exec_command.ex
+++ b/deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/exec_command.ex
@@ -30,7 +30,7 @@ defmodule RabbitMQ.CLI.Ctl.Commands.ExecCommand do
def validate([string], _) do
try do
- Code.compile_string(string)
+ _ = Code.compile_string(string)
:ok
rescue
ex in SyntaxError ->
diff --git a/deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/export_definitions_command.ex b/deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/export_definitions_command.ex
index f0088e872d..c009c79d18 100644
--- a/deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/export_definitions_command.ex
+++ b/deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/export_definitions_command.ex
@@ -41,7 +41,7 @@ defmodule RabbitMQ.CLI.Ctl.Commands.ExportDefinitionsCommand do
def validate([path], _) do
dir = Path.dirname(path)
- case File.exists?(dir, raw: true) do
+ case File.exists?(dir, [:raw]) do
true -> :ok
false -> {:validation_failure, {:bad_argument, "Directory #{dir} does not exist"}}
end
@@ -76,7 +76,7 @@ defmodule RabbitMQ.CLI.Ctl.Commands.ExportDefinitionsCommand do
body = serialise(result, format)
abs_path = Path.absname(path)
- File.rm(abs_path)
+ _ = File.rm(abs_path)
case File.write(abs_path, body) do
# no output
diff --git a/deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/forget_cluster_node_command.ex b/deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/forget_cluster_node_command.ex
index e158d00a28..064b51baf0 100644
--- a/deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/forget_cluster_node_command.ex
+++ b/deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/forget_cluster_node_command.ex
@@ -38,7 +38,7 @@ defmodule RabbitMQ.CLI.Ctl.Commands.ForgetClusterNodeCommand do
Stream.concat([
become(node_name, opts),
RabbitMQ.CLI.Core.Helpers.defer(fn ->
- :rabbit_event.start_link()
+ _ = :rabbit_event.start_link()
:rabbit_mnesia.forget_cluster_node(to_atom(node_to_remove), true)
end)
])
diff --git a/deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/help_command.ex b/deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/help_command.ex
index b39f089819..982c920023 100644
--- a/deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/help_command.ex
+++ b/deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/help_command.ex
@@ -28,7 +28,7 @@ defmodule RabbitMQ.CLI.Ctl.Commands.HelpCommand do
end
def run([command_name | _], opts) do
- CommandModules.load(opts)
+ _ = CommandModules.load(opts)
module_map = CommandModules.module_map(opts)
@@ -54,7 +54,7 @@ defmodule RabbitMQ.CLI.Ctl.Commands.HelpCommand do
end
def run([], opts) do
- CommandModules.load(opts)
+ _ = CommandModules.load(opts)
case opts[:list_commands] do
true ->
diff --git a/deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/import_definitions_command.ex b/deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/import_definitions_command.ex
index 50f7463661..665b821fcc 100644
--- a/deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/import_definitions_command.ex
+++ b/deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/import_definitions_command.ex
@@ -31,7 +31,7 @@ defmodule RabbitMQ.CLI.Ctl.Commands.ImportDefinitionsCommand do
end
def validate([path], _) do
- case File.exists?(path, raw: true) do
+ case File.exists?(path, [:raw]) do
true -> :ok
false -> {:validation_failure, {:bad_argument, "File #{path} does not exist"}}
end
@@ -42,7 +42,7 @@ defmodule RabbitMQ.CLI.Ctl.Commands.ImportDefinitionsCommand do
use RabbitMQ.CLI.Core.RequiresRabbitAppRunning
def run([], %{node: node_name, format: format, timeout: timeout}) do
- case IO.read(:stdio, :all) do
+ case IO.read(:stdio, :eof) do
:eof ->
{:error, :not_enough_args}
diff --git a/deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/list_channels_command.ex b/deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/list_channels_command.ex
index cebe5dfaf1..01075a42dc 100644
--- a/deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/list_channels_command.ex
+++ b/deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/list_channels_command.ex
@@ -38,7 +38,7 @@ defmodule RabbitMQ.CLI.Ctl.Commands.ListChannelsCommand do
use RabbitMQ.CLI.Core.RequiresRabbitAppRunning
def run([], opts) do
- run(~w(pid user consumer_count messages_unacknowledged), opts)
+ run(~w(pid user consumer_count messages_unacknowledged) |> Enum.map(&to_charlist/1), opts)
end
def run([_ | _] = args, %{node: node_name, timeout: timeout}) do
diff --git a/deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/wait_command.ex b/deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/wait_command.ex
index 112d791131..648f8eade7 100644
--- a/deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/wait_command.ex
+++ b/deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/wait_command.ex
@@ -207,10 +207,7 @@ defmodule RabbitMQ.CLI.Ctl.Commands.WaitCommand do
end
defp wait_for_application(node_name, :rabbit_and_plugins) do
- case :rabbit.await_startup(node_name) do
- {:badrpc, err} -> {:error, {:badrpc, err}}
- other -> other
- end
+ :rabbit.await_startup(node_name)
end
defp wait_for_erlang_distribution(pid, node_name, timeout) do
diff --git a/deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/info_keys.ex b/deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/info_keys.ex
index b56f706502..345ad46495 100644
--- a/deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/info_keys.ex
+++ b/deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/info_keys.ex
@@ -9,7 +9,7 @@ defmodule RabbitMQ.CLI.Ctl.InfoKeys do
alias RabbitMQ.CLI.Core.DataCoercion
# internal to requested keys
- @type info_keys :: Erlang.proplist()
+ @type info_keys :: [atom | tuple]
# requested to internal keys
@type aliases :: keyword(atom)
diff --git a/deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/rpc_stream.ex b/deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/rpc_stream.ex
index 38044233aa..cd2a44dbe0 100644
--- a/deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/rpc_stream.ex
+++ b/deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/rpc_stream.ex
@@ -26,7 +26,10 @@ defmodule RabbitMQ.CLI.Ctl.RpcStream do
def receive_list_items_with_fun(node, mfas, timeout, info_keys, chunks_init, response_fun) do
pid = Kernel.self()
ref = Kernel.make_ref()
- for {m, f, a} <- mfas, do: init_items_stream(node, m, f, a, timeout, pid, ref)
+
+ Enum.each(mfas, fn {m, f, a} ->
+ init_items_stream(node, m, f, a, timeout, pid, ref)
+ end)
Stream.unfold(
{chunks_init, :continue},
diff --git a/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/erlang_cookie_sources_command.ex b/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/erlang_cookie_sources_command.ex
index adc56c453b..1e6219de1a 100644
--- a/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/erlang_cookie_sources_command.ex
+++ b/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/erlang_cookie_sources_command.ex
@@ -48,7 +48,7 @@ defmodule RabbitMQ.CLI.Diagnostics.Commands.ErlangCookieSourcesCommand do
os_env_cookie_set: System.get_env("RABBITMQ_ERLANG_COOKIE") != nil,
os_env_cookie_value_length: String.length(System.get_env("RABBITMQ_ERLANG_COOKIE") || ""),
switch_cookie_set: switch_cookie != nil,
- switch_cookie_value_length: String.length(to_string(switch_cookie) || ""),
+ switch_cookie_value_length: String.length(to_string(switch_cookie)),
effective_user: System.get_env("USER"),
home_dir: home_dir,
cookie_file_path: cookie_file_path,
diff --git a/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/observer_command.ex b/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/observer_command.ex
index 5cc1af646a..c0f2263860 100644
--- a/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/observer_command.ex
+++ b/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/observer_command.ex
@@ -17,6 +17,7 @@ defmodule RabbitMQ.CLI.Diagnostics.Commands.ObserverCommand do
use RabbitMQ.CLI.Core.AcceptsNoPositionalArguments
+ @dialyzer {:nowarn_function, run: 2}
def run([], %{node: node_name, interval: interval}) do
case :observer_cli.start(node_name, [{:interval, interval * 1000}]) do
# See zhongwencool/observer_cli#54
diff --git a/deps/rabbitmq_cli/lib/rabbitmq/cli/formatters/report.ex b/deps/rabbitmq_cli/lib/rabbitmq/cli/formatters/report.ex
index 345284f31f..98fefae643 100644
--- a/deps/rabbitmq_cli/lib/rabbitmq/cli/formatters/report.ex
+++ b/deps/rabbitmq_cli/lib/rabbitmq/cli/formatters/report.ex
@@ -9,6 +9,7 @@ defmodule RabbitMQ.CLI.Formatters.Report do
alias RabbitMQ.CLI.Core.{Output, Config}
@behaviour RabbitMQ.CLI.FormatterBehaviour
+ @dialyzer {:nowarn_function, format_output: 2}
def format_output(_, _) do
raise "format_output is not implemented for report formatter"
end
diff --git a/deps/rabbitmq_cli/lib/rabbitmq/cli/formatters/string_per_line.ex b/deps/rabbitmq_cli/lib/rabbitmq/cli/formatters/string_per_line.ex
index 56da194aee..85ae2ed81c 100644
--- a/deps/rabbitmq_cli/lib/rabbitmq/cli/formatters/string_per_line.ex
+++ b/deps/rabbitmq_cli/lib/rabbitmq/cli/formatters/string_per_line.ex
@@ -17,7 +17,7 @@ defmodule RabbitMQ.CLI.Formatters.StringPerLine do
@behaviour RabbitMQ.CLI.FormatterBehaviour
def format_output(output, _) do
- Enum.map(output, fn el -> Helpers.string_or_inspect(el) end)
+ Enum.map(output, fn el -> Helpers.string_or_inspect(el) end) |> Enum.join()
end
def format_stream(stream, options) do
diff --git a/deps/rabbitmq_cli/lib/rabbitmq/cli/plugins/plugins_helpers.ex b/deps/rabbitmq_cli/lib/rabbitmq/cli/plugins/plugins_helpers.ex
index fa0ac9ddb4..59341f42c8 100644
--- a/deps/rabbitmq_cli/lib/rabbitmq/cli/plugins/plugins_helpers.ex
+++ b/deps/rabbitmq_cli/lib/rabbitmq/cli/plugins/plugins_helpers.ex
@@ -79,7 +79,7 @@ defmodule RabbitMQ.CLI.Plugins.Helpers do
def set_enabled_plugins(plugins, opts) do
plugin_atoms = :lists.usort(for plugin <- plugins, do: to_atom(plugin))
- require_rabbit_and_plugins(opts)
+ _ = require_rabbit_and_plugins(opts)
{:ok, plugins_file} = enabled_plugins_file(opts)
write_enabled_plugins(plugin_atoms, plugins_file, opts)
end
@@ -223,7 +223,7 @@ defmodule RabbitMQ.CLI.Plugins.Helpers do
defp add_all_to_path(plugins_directories) do
directories = String.split(to_string(plugins_directories), path_separator())
- Enum.map(directories, fn directory ->
+ Enum.each(directories, fn directory ->
with {:ok, subdirs} <- File.ls(directory) do
for subdir <- subdirs do
Path.join([directory, subdir, "ebin"])
diff --git a/deps/rabbitmq_cli/lib/rabbitmq/cli/queues/commands/peek_command.ex b/deps/rabbitmq_cli/lib/rabbitmq/cli/queues/commands/peek_command.ex
index 524a8547f6..f8ea0b95e2 100644
--- a/deps/rabbitmq_cli/lib/rabbitmq/cli/queues/commands/peek_command.ex
+++ b/deps/rabbitmq_cli/lib/rabbitmq/cli/queues/commands/peek_command.ex
@@ -27,7 +27,6 @@ defmodule RabbitMQ.CLI.Queues.Commands.PeekCommand do
case Integer.parse(raw_pos) do
{n, _} -> n
:error -> :error
- _ -> :error
end
invalid_pos = {:validation_failure, "position value must be a positive integer"}
diff --git a/deps/rabbitmq_cli/lib/rabbitmqctl.ex b/deps/rabbitmq_cli/lib/rabbitmqctl.ex
index 179c44d002..ea84c812ad 100644
--- a/deps/rabbitmq_cli/lib/rabbitmqctl.ex
+++ b/deps/rabbitmq_cli/lib/rabbitmqctl.ex
@@ -24,6 +24,7 @@ defmodule RabbitMQCtl do
@type options() :: map()
@type command_result() :: {:error, ExitCodes.exit_code(), term()} | term()
+ @spec main(list(string())) :: no_return()
def main(["--auto-complete" | []]) do
handle_shutdown(:ok)
end
@@ -152,7 +153,7 @@ defmodule RabbitMQCtl do
end
defp proceed_to_execution(command, arguments, options) do
- maybe_print_banner(command, arguments, options)
+ _ = maybe_print_banner(command, arguments, options)
maybe_run_command(command, arguments, options)
end
@@ -236,6 +237,7 @@ defmodule RabbitMQCtl do
end
end
+ @spec handle_shutdown({:error, integer(), nil}) :: no_return()
defp handle_shutdown({:error, exit_code, nil}) do
exit_program(exit_code)
end
@@ -243,9 +245,9 @@ defmodule RabbitMQCtl do
defp handle_shutdown({_, exit_code, output}) do
device = output_device(exit_code)
- for line <- List.flatten([output]) do
+ Enum.each(List.flatten([output]), fn line ->
IO.puts(device, Helpers.string_or_inspect(line))
- end
+ end)
exit_program(exit_code)
end
@@ -393,8 +395,9 @@ defmodule RabbitMQCtl do
defp format_validation_error(err), do: inspect(err)
+ @spec exit_program(integer()) :: no_return()
defp exit_program(code) do
- :net_kernel.stop()
+ _ = :net_kernel.stop()
exit({:shutdown, code})
end
diff --git a/deps/rabbitmq_cli/rabbitmqctl.bzl b/deps/rabbitmq_cli/rabbitmqctl.bzl
index 289bc7da01..697a504ab8 100644
--- a/deps/rabbitmq_cli/rabbitmqctl.bzl
+++ b/deps/rabbitmq_cli/rabbitmqctl.bzl
@@ -270,9 +270,24 @@ done
),
)
+ (_, _, erlang_runfiles) = erlang_dirs(ctx)
+ (_, elixir_runfiles) = elixir_dirs(ctx)
+
lib_info = ctx.attr.elixir_app[ElixirAppInfo]
+
+ runfiles = ctx.runfiles([ebin]).merge_all([
+ erlang_runfiles,
+ elixir_runfiles,
+ ] + [
+ dep[DefaultInfo].default_runfiles
+ for dep in lib_info.deps
+ ])
+
return [
- DefaultInfo(files = depset([ebin])),
+ DefaultInfo(
+ files = depset([ebin]),
+ runfiles = runfiles,
+ ),
ErlangAppInfo(
app_name = lib_info.app_name,
extra_apps = lib_info.extra_apps,
@@ -303,6 +318,9 @@ elixir_app_to_erlang_app = rule(
],
),
},
+ toolchains = [
+ "//bazel/elixir:toolchain_type",
+ ],
provides = [ErlangAppInfo],
)
diff --git a/deps/rabbitmq_cli/rabbitmqctl_test.bzl b/deps/rabbitmq_cli/rabbitmqctl_test.bzl
index b8083aab6c..9b775ec0af 100644
--- a/deps/rabbitmq_cli/rabbitmqctl_test.bzl
+++ b/deps/rabbitmq_cli/rabbitmqctl_test.bzl
@@ -75,7 +75,6 @@ export ERL_COMPILER_OPTIONS=deterministic
"${{ABS_ELIXIR_HOME}}"/bin/mix local.hex --force
"${{ABS_ELIXIR_HOME}}"/bin/mix local.rebar --force
"${{ABS_ELIXIR_HOME}}"/bin/mix deps.get
-# "${{ABS_ELIXIR_HOME}}"/bin/mix dialyzer
if [ ! -d _build/${{MIX_ENV}}/lib/rabbit_common ]; then
cp -r ${{DEPS_DIR}}/* _build/${{MIX_ENV}}/lib
fi
@@ -140,7 +139,7 @@ cd %OUTPUTS_DIR% || goto :error
set DEPS_DIR=%TEST_SRCDIR%/%TEST_WORKSPACE%/{package_dir}/{deps_dir}
set DEPS_DIR=%DEPS_DIR:/=\\%
set ERL_COMPILER_OPTIONS=deterministic
-set MIX_ENV=test mix dialyzer
+set MIX_ENV=test
echo y | "{elixir_home}\\bin\\mix" local.hex --force || goto :error
echo y | "{elixir_home}\\bin\\mix" local.rebar --force || goto :error
"{elixir_home}\\bin\\mix" deps.get || goto :error