Skip to content

Commit 875fe9a

Browse files
Merge pull request #10459 from rabbitmq/md-elixir-warnings
Resolve CLI elixirc warnings
2 parents 1aa9e13 + c285651 commit 875fe9a

14 files changed

+264
-35
lines changed

deps/rabbitmq_cli/BUILD.bazel

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
load("@rules_erlang//:dialyze.bzl", "dialyze", "plt")
22
load(":rabbitmqctl.bzl", "rabbitmqctl")
33
load(":rabbitmqctl_check_formatted.bzl", "rabbitmqctl_check_formatted_test")
4+
load(":rabbitmqctl_compile_warnings_as_errors.bzl", "rabbitmqctl_compile_warnings_as_errors_test")
45
load(":rabbitmqctl_test.bzl", "rabbitmqctl_test")
56
load("//:rabbitmq_home.bzl", "rabbitmq_home")
67
load("//:rabbitmq_run.bzl", "rabbitmq_run")
@@ -97,6 +98,52 @@ test_suite(
9798
tests = ["check_formatted"],
9899
)
99100

101+
rabbitmqctl_compile_warnings_as_errors_test(
102+
name = "compile_warnings_as_errors",
103+
size = "small",
104+
srcs = [
105+
".formatter.exs",
106+
"config/config.exs",
107+
"mix.exs",
108+
] + glob([
109+
"lib/**/*.ex",
110+
"test/**/*.exs",
111+
]),
112+
data = glob(["test/fixtures/**/*"]),
113+
archives = [
114+
"@hex//:archive",
115+
],
116+
source_deps = {
117+
"@amqp//:sources": "amqp",
118+
"@csv//:sources": "csv",
119+
"@json//:sources": "json",
120+
"@temp//:sources": "temp",
121+
"@x509//:sources": "x509",
122+
},
123+
deps = [
124+
"//deps/amqp_client:erlang_app",
125+
"//deps/rabbit:erlang_app",
126+
"//deps/rabbit_common:erlang_app",
127+
"@observer_cli//:erlang_app",
128+
"@stdout_formatter//:erlang_app",
129+
],
130+
target_compatible_with = select({
131+
"@platforms//os:macos": [
132+
"@platforms//os:macos",
133+
"@elixir_config//:elixir_1_15",
134+
],
135+
"//conditions:default": [
136+
"@platforms//os:linux",
137+
"@elixir_config//:elixir_1_15",
138+
],
139+
}),
140+
)
141+
142+
test_suite(
143+
name = "rabbitmqctl_compile_warnings_as_errors",
144+
tests = ["compile_warnings_as_errors"],
145+
)
146+
100147
plt(
101148
name = "deps_plt",
102149
apps = [

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ defmodule RabbitMQ.CLI.Core.CommandModules do
6969
{:ok, enabled_plugins_file} = PluginsHelpers.enabled_plugins_file(opts)
7070
require Logger
7171

72-
Logger.warn(
72+
Logger.warning(
7373
"Unable to read the enabled plugins file.\n" <>
7474
" Reason: #{inspect(err)}\n" <>
7575
" Commands provided by plugins will not be available.\n" <>

deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/add_user_command.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ defmodule RabbitMQ.CLI.Ctl.Commands.AddUserCommand do
8383

8484
def run(
8585
[username, base64_encoded_password_hash],
86-
%{node: node_name, pre_hashed_password: true} = opts
86+
%{node: node_name, pre_hashed_password: true}
8787
) do
8888
case Base.decode64(base64_encoded_password_hash) do
8989
{:ok, password_hash} ->

deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/force_standalone_khepri_boot.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
## Copyright (c) 2007-2023 Broadcom. All Rights Reserved. The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. All rights reserved.
66

77
defmodule RabbitMQ.CLI.Ctl.Commands.ForceStandaloneKhepriBootCommand do
8-
alias RabbitMQ.CLI.Core.{Config, DocGuide}
8+
alias RabbitMQ.CLI.Core.DocGuide
99

1010
@behaviour RabbitMQ.CLI.CommandBehaviour
1111

1212
use RabbitMQ.CLI.Core.MergesNoDefaults
1313
use RabbitMQ.CLI.Core.AcceptsNoPositionalArguments
1414

15-
def run([], %{node: node_name} = opts) do
15+
def run([], %{node: node_name}) do
1616
ret =
1717
:rabbit_misc.rpc_call(node_name, :rabbit_khepri, :force_shrink_member_to_current_member, [])
1818

deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/forget_cluster_node_command.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ defmodule RabbitMQ.CLI.Ctl.Commands.ForgetClusterNodeCommand do
7272
{:error,
7373
"RabbitMQ on node #{node_to_remove} must be stopped with 'rabbitmqctl -n #{node_to_remove} stop_app' before it can be removed"}
7474

75-
{:error, {:failed_to_remove_node, ^atom_name, unavailable}} ->
75+
{:error, {:failed_to_remove_node, ^atom_name, :unavailable}} ->
7676
{:error, "Node #{node_to_remove} must be running before it can be removed"}
7777

7878
{:error, _} = error ->

deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/join_cluster_command.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ defmodule RabbitMQ.CLI.Ctl.Commands.JoinClusterCommand do
7676
"Error: cannot cluster node with itself: #{node_name}"}
7777
end
7878

79-
def output({:error, {:node_type_unsupported, db, node_type}}, %{node: node_name}) do
79+
def output({:error, {:node_type_unsupported, db, node_type}}, %{node: _node_name}) do
8080
{:error, RabbitMQ.CLI.Core.ExitCodes.exit_software(),
8181
"Error: `#{node_type}` node type is unsupported by the #{db} by database engine"}
8282
end

deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/rename_cluster_node_command.ex

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66

77
defmodule RabbitMQ.CLI.Ctl.Commands.RenameClusterNodeCommand do
88
require Integer
9-
alias RabbitMQ.CLI.Core.{DocGuide, Validators}
10-
import RabbitMQ.CLI.Core.DataCoercion
9+
alias RabbitMQ.CLI.Core.DocGuide
1110

1211
@behaviour RabbitMQ.CLI.CommandBehaviour
1312

@@ -21,7 +20,7 @@ defmodule RabbitMQ.CLI.Ctl.Commands.RenameClusterNodeCommand do
2120
:ok
2221
end
2322

24-
def run(nodes, %{node: node_name}) do
23+
def run(_nodes, %{node: _node_name}) do
2524
:ok
2625
end
2726

deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/update_cluster_nodes_command.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
## Copyright (c) 2007-2024 Broadcom. All Rights Reserved. The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. All rights reserved.
66

77
defmodule RabbitMQ.CLI.Ctl.Commands.UpdateClusterNodesCommand do
8-
alias RabbitMQ.CLI.Core.{Config, DocGuide, Helpers}
8+
alias RabbitMQ.CLI.Core.DocGuide
99

1010
@behaviour RabbitMQ.CLI.CommandBehaviour
1111

deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/check_if_any_deprecated_features_are_used_command.ex

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@
55
## Copyright (c) 2007-2023 Broadcom. All Rights Reserved. The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. All rights reserved.
66

77
defmodule RabbitMQ.CLI.Diagnostics.Commands.CheckIfAnyDeprecatedFeaturesAreUsedCommand do
8-
alias RabbitMQ.CLI.Core.DocGuide
9-
10-
alias RabbitMQ.CLI.Diagnostics.Commands.{
11-
CheckIfClusterHasClassicQueueMirroringPolicyCommand
12-
}
13-
148
@behaviour RabbitMQ.CLI.CommandBehaviour
159

1610
def scopes(), do: [:ctl, :diagnostics]
@@ -100,16 +94,5 @@ defmodule RabbitMQ.CLI.Diagnostics.Commands.CheckIfAnyDeprecatedFeaturesAreUsedC
10094
def description(),
10195
do: "Generate a report listing all deprecated features in use"
10296

103-
def banner(_, %{node: node_name}), do: "Checking if any deprecated features are used ..."
104-
105-
#
106-
# Implementation
107-
#
108-
109-
defp run_command(command, args, opts) do
110-
{args, opts} = command.merge_defaults(args, opts)
111-
banner = command.banner(args, opts)
112-
command_result = command.run(args, opts) |> command.output(opts)
113-
{command, banner, command_result}
114-
end
97+
def banner(_, %{node: _node_name}), do: "Checking if any deprecated features are used ..."
11598
end

deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/list_policies_that_match.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,16 @@ defmodule RabbitMQ.CLI.Diagnostics.Commands.ListPoliciesThatMatchCommand do
5656
end
5757
end
5858

59-
def output([], %{node: node_name, formatter: "json"}) do
59+
def output([], %{node: _node_name, formatter: "json"}) do
6060
{:ok, %{"result" => "ok", "policies" => []}}
6161
end
6262

63-
def output({:error, :not_found}, %{node: node_name, formatter: "json"}) do
63+
def output({:error, :not_found}, %{node: _node_name, formatter: "json"}) do
6464
{:ok,
6565
%{"result" => "error", "message" => "object (queue, exchange) not found", "policies" => []}}
6666
end
6767

68-
def output(value, %{node: node_name, formatter: "json"}) when is_list(value) do
68+
def output(value, %{node: _node_name, formatter: "json"}) when is_list(value) do
6969
{:ok, %{"result" => "ok", "policies" => value}}
7070
end
7171

deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/metadata_store_status_command.ex

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
## Copyright (c) 2022 VMware, Inc. or its affiliates. All rights reserved.
66

77
defmodule RabbitMQ.CLI.Diagnostics.Commands.MetadataStoreStatusCommand do
8-
alias RabbitMQ.CLI.Core.DocGuide
9-
108
@behaviour RabbitMQ.CLI.CommandBehaviour
119
def scopes(), do: [:diagnostics]
1210

deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/remote_shell_command.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ defmodule RabbitMQ.CLI.Diagnostics.Commands.RemoteShellCommand do
3838
case :shell.start_interactive({node_name, {:shell, :start, []}}) do
3939
:ok -> :ok
4040
{:error, :already_started} -> :ok
41-
{error, _} -> {:error, {:badrpc, :nodedown}}
41+
{:error, _} -> {:error, {:badrpc, :nodedown}}
4242
end
4343

4444
:timer.sleep(:infinity)

deps/rabbitmq_cli/lib/rabbitmq/cli/streams/commands/coordinator_status_command.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@ defmodule RabbitMQ.CLI.Queues.Commands.CoordinatorStatusCommand do
4747

4848
def description(), do: "Displays raft status of the stream coordinator"
4949

50-
def banner([], %{node: node_name}),
50+
def banner([], %{node: _node_name}),
5151
do: "Status of stream coordinator ..."
5252
end

0 commit comments

Comments
 (0)