Skip to content

Commit bdb2046

Browse files
authored
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 c16b5b6. * Use rules_erlang 3.9.2
1 parent b02c268 commit bdb2046

30 files changed

+86
-47
lines changed

MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ bazel_dep(
3131

3232
bazel_dep(
3333
name = "rules_erlang",
34-
version = "3.9.1",
34+
version = "3.9.2",
3535
)
3636

3737
erlang_config = use_extension(

WORKSPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository", "new_git_r
44
git_repository(
55
name = "rules_erlang",
66
remote = "https://github.com/rabbitmq/rules_erlang.git",
7-
tag = "3.9.1",
7+
tag = "3.9.2",
88
)
99

1010
load("@rules_erlang//:internal_deps.bzl", "rules_erlang_internal_deps")

deps/rabbit_common/src/rabbit_misc.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@
232232
-spec pset(term(), term(), [term()]) -> [term()].
233233
-spec format_message_queue(any(), priority_queue:q()) -> term().
234234
-spec os_cmd(string()) -> string().
235-
-spec is_os_process_alive(non_neg_integer()) -> boolean().
235+
-spec is_os_process_alive(non_neg_integer() | string()) -> boolean().
236236
-spec version() -> string().
237237
-spec otp_release() -> string().
238238
-spec otp_system_version() -> string().

deps/rabbitmq_cli/BUILD.bazel

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
load("@bazel_skylib//rules:select_file.bzl", "select_file")
2+
load("@rules_erlang//:dialyze.bzl", "dialyze", "plt")
23
load(":rabbitmqctl.bzl", "rabbitmqctl")
34
load(":rabbitmqctl_check_formatted.bzl", "rabbitmqctl_check_formatted_test")
45
load(":rabbitmqctl_test.bzl", "rabbitmqctl_test")
56
load("//:rabbitmq_home.bzl", "rabbitmq_home")
67
load("//:rabbitmq_run.bzl", "rabbitmq_run")
7-
load("//:rabbitmq.bzl", "STARTS_BACKGROUND_BROKER_TAG")
8+
load("//:rabbitmq.bzl", "RABBITMQ_DIALYZER_OPTS", "STARTS_BACKGROUND_BROKER_TAG")
89

910
# Note: All the various rabbitmq-* scripts are just copies of rabbitmqctl
1011
rabbitmqctl(
@@ -71,6 +72,22 @@ test_suite(
7172
tests = ["check_formatted"],
7273
)
7374

75+
plt(
76+
name = "deps_plt",
77+
libs = [":elixir"],
78+
deps = [
79+
":elixir",
80+
"//deps/rabbit:erlang_app",
81+
"//deps/rabbit_common:erlang_app",
82+
],
83+
)
84+
85+
dialyze(
86+
dialyzer_opts = RABBITMQ_DIALYZER_OPTS,
87+
libs = [":elixir"],
88+
plt = ":deps_plt",
89+
)
90+
7491
rabbitmqctl_test(
7592
name = "tests",
7693
size = "large",

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ defmodule RabbitMQ.CLI.CommandBehaviour do
4747
@callback printer() :: atom()
4848
@callback scopes() :: [atom()] | nil
4949
@callback description() :: String.t()
50-
@callback help_section() :: String.t() | {:plugin, atom()}
50+
@callback help_section() :: String.t() | atom() | {:plugin, atom()}
5151
@callback usage_additional() ::
5252
String.t()
5353
| [String.t()]

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ defmodule RabbitMQ.CLI.Core.CodePath do
1515
val ->
1616
with {:ok, plugins_dir} <- val do
1717
String.split(to_string(plugins_dir), Platform.path_separator())
18-
|> Enum.map(&add_directory_plugins_to_load_path/1)
18+
|> Enum.each(&add_directory_plugins_to_load_path/1)
1919

2020
:ok
2121
end
@@ -99,11 +99,11 @@ defmodule RabbitMQ.CLI.Core.CodePath do
9999
_ ->
100100
case Application.load(:rabbit) do
101101
:ok ->
102-
Code.ensure_loaded(:rabbit_plugins)
102+
_ = Code.ensure_loaded(:rabbit_plugins)
103103
:ok
104104

105105
{:error, {:already_loaded, :rabbit}} ->
106-
Code.ensure_loaded(:rabbit_plugins)
106+
_ = Code.ensure_loaded(:rabbit_plugins)
107107
:ok
108108

109109
{:error, err} ->

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ defmodule RabbitMQ.CLI.Core.CommandModules do
5959
end
6060

6161
def plugin_modules(opts) do
62-
require_rabbit(opts)
62+
_ = require_rabbit(opts)
6363

6464
enabled_plugins =
6565
try do

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ defmodule RabbitMQ.CLI.Core.Helpers do
130130
end
131131

132132
def apply_if_exported(mod, fun, args, default) do
133-
Code.ensure_loaded(mod)
133+
_ = Code.ensure_loaded(mod)
134134

135135
case function_exported?(mod, fun, length(args)) do
136136
true -> apply(mod, fun, args)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ defmodule RabbitMQ.CLI.Core.Input do
2626
end
2727

2828
def consume_multiline_string() do
29-
val = IO.read(:stdio, :all)
29+
val = IO.read(:stdio, :eof)
3030

3131
case val do
3232
:eof -> :eof

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ defmodule RabbitMQ.CLI.Core.Memory do
9090
end
9191

9292
def parse_watermark(n) when is_bitstring(n) do
93-
case IU.parse(n) do
93+
case IU.parse(to_charlist(n)) do
9494
{:ok, parsed} -> parsed
9595
err -> err
9696
end

0 commit comments

Comments
 (0)