Skip to content

Resolve CLI elixirc warnings #10459

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions deps/rabbitmq_cli/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
load("@rules_erlang//:dialyze.bzl", "dialyze", "plt")
load(":rabbitmqctl.bzl", "rabbitmqctl")
load(":rabbitmqctl_check_formatted.bzl", "rabbitmqctl_check_formatted_test")
load(":rabbitmqctl_compile_warnings_as_errors.bzl", "rabbitmqctl_compile_warnings_as_errors_test")
load(":rabbitmqctl_test.bzl", "rabbitmqctl_test")
load("//:rabbitmq_home.bzl", "rabbitmq_home")
load("//:rabbitmq_run.bzl", "rabbitmq_run")
Expand Down Expand Up @@ -97,6 +98,52 @@ test_suite(
tests = ["check_formatted"],
)

rabbitmqctl_compile_warnings_as_errors_test(
name = "compile_warnings_as_errors",
size = "small",
srcs = [
".formatter.exs",
"config/config.exs",
"mix.exs",
] + glob([
"lib/**/*.ex",
"test/**/*.exs",
]),
data = glob(["test/fixtures/**/*"]),
archives = [
"@hex//:archive",
],
source_deps = {
"@amqp//:sources": "amqp",
"@csv//:sources": "csv",
"@json//:sources": "json",
"@temp//:sources": "temp",
"@x509//:sources": "x509",
},
deps = [
"//deps/amqp_client:erlang_app",
"//deps/rabbit:erlang_app",
"//deps/rabbit_common:erlang_app",
"@observer_cli//:erlang_app",
"@stdout_formatter//:erlang_app",
],
target_compatible_with = select({
"@platforms//os:macos": [
"@platforms//os:macos",
"@elixir_config//:elixir_1_15",
],
"//conditions:default": [
"@platforms//os:linux",
"@elixir_config//:elixir_1_15",
],
}),
)

test_suite(
name = "rabbitmqctl_compile_warnings_as_errors",
tests = ["compile_warnings_as_errors"],
)

plt(
name = "deps_plt",
apps = [
Expand Down
2 changes: 1 addition & 1 deletion deps/rabbitmq_cli/lib/rabbitmq/cli/core/command_modules.ex
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ defmodule RabbitMQ.CLI.Core.CommandModules do
{:ok, enabled_plugins_file} = PluginsHelpers.enabled_plugins_file(opts)
require Logger

Logger.warn(
Logger.warning(
"Unable to read the enabled plugins file.\n" <>
" Reason: #{inspect(err)}\n" <>
" Commands provided by plugins will not be available.\n" <>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ defmodule RabbitMQ.CLI.Ctl.Commands.AddUserCommand do

def run(
[username, base64_encoded_password_hash],
%{node: node_name, pre_hashed_password: true} = opts
%{node: node_name, pre_hashed_password: true}
) do
case Base.decode64(base64_encoded_password_hash) do
{:ok, password_hash} ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
## Copyright (c) 2007-2023 Broadcom. All Rights Reserved. The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. All rights reserved.

defmodule RabbitMQ.CLI.Ctl.Commands.ForceStandaloneKhepriBootCommand do
alias RabbitMQ.CLI.Core.{Config, DocGuide}
alias RabbitMQ.CLI.Core.DocGuide

@behaviour RabbitMQ.CLI.CommandBehaviour

use RabbitMQ.CLI.Core.MergesNoDefaults
use RabbitMQ.CLI.Core.AcceptsNoPositionalArguments

def run([], %{node: node_name} = opts) do
def run([], %{node: node_name}) do
ret =
:rabbit_misc.rpc_call(node_name, :rabbit_khepri, :force_shrink_member_to_current_member, [])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ defmodule RabbitMQ.CLI.Ctl.Commands.ForgetClusterNodeCommand do
{:error,
"RabbitMQ on node #{node_to_remove} must be stopped with 'rabbitmqctl -n #{node_to_remove} stop_app' before it can be removed"}

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

{:error, _} = error ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ defmodule RabbitMQ.CLI.Ctl.Commands.JoinClusterCommand do
"Error: cannot cluster node with itself: #{node_name}"}
end

def output({:error, {:node_type_unsupported, db, node_type}}, %{node: node_name}) do
def output({:error, {:node_type_unsupported, db, node_type}}, %{node: _node_name}) do
{:error, RabbitMQ.CLI.Core.ExitCodes.exit_software(),
"Error: `#{node_type}` node type is unsupported by the #{db} by database engine"}
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

defmodule RabbitMQ.CLI.Ctl.Commands.RenameClusterNodeCommand do
require Integer
alias RabbitMQ.CLI.Core.{DocGuide, Validators}
import RabbitMQ.CLI.Core.DataCoercion
alias RabbitMQ.CLI.Core.DocGuide

@behaviour RabbitMQ.CLI.CommandBehaviour

Expand All @@ -21,7 +20,7 @@ defmodule RabbitMQ.CLI.Ctl.Commands.RenameClusterNodeCommand do
:ok
end

def run(nodes, %{node: node_name}) do
def run(_nodes, %{node: _node_name}) do
:ok
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
## Copyright (c) 2007-2024 Broadcom. All Rights Reserved. The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. All rights reserved.

defmodule RabbitMQ.CLI.Ctl.Commands.UpdateClusterNodesCommand do
alias RabbitMQ.CLI.Core.{Config, DocGuide, Helpers}
alias RabbitMQ.CLI.Core.DocGuide

@behaviour RabbitMQ.CLI.CommandBehaviour

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@
## Copyright (c) 2007-2023 Broadcom. All Rights Reserved. The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. All rights reserved.

defmodule RabbitMQ.CLI.Diagnostics.Commands.CheckIfAnyDeprecatedFeaturesAreUsedCommand do
alias RabbitMQ.CLI.Core.DocGuide

alias RabbitMQ.CLI.Diagnostics.Commands.{
CheckIfClusterHasClassicQueueMirroringPolicyCommand
}

@behaviour RabbitMQ.CLI.CommandBehaviour

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

def banner(_, %{node: node_name}), do: "Checking if any deprecated features are used ..."

#
# Implementation
#

defp run_command(command, args, opts) do
{args, opts} = command.merge_defaults(args, opts)
banner = command.banner(args, opts)
command_result = command.run(args, opts) |> command.output(opts)
{command, banner, command_result}
end
def banner(_, %{node: _node_name}), do: "Checking if any deprecated features are used ..."
end
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,16 @@ defmodule RabbitMQ.CLI.Diagnostics.Commands.ListPoliciesThatMatchCommand do
end
end

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

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
## Copyright (c) 2022 VMware, Inc. or its affiliates. All rights reserved.

defmodule RabbitMQ.CLI.Diagnostics.Commands.MetadataStoreStatusCommand do
alias RabbitMQ.CLI.Core.DocGuide

@behaviour RabbitMQ.CLI.CommandBehaviour
def scopes(), do: [:diagnostics]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ defmodule RabbitMQ.CLI.Diagnostics.Commands.RemoteShellCommand do
case :shell.start_interactive({node_name, {:shell, :start, []}}) do
:ok -> :ok
{:error, :already_started} -> :ok
{error, _} -> {:error, {:badrpc, :nodedown}}
{:error, _} -> {:error, {:badrpc, :nodedown}}
end

:timer.sleep(:infinity)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ defmodule RabbitMQ.CLI.Queues.Commands.CoordinatorStatusCommand do

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

def banner([], %{node: node_name}),
def banner([], %{node: _node_name}),
do: "Status of stream coordinator ..."
end
Loading