Fix dialyzer warnings in rabbit_common

This commit is contained in:
Rin Kuryloski 2022-12-01 11:21:13 +01:00
parent 344e4553ba
commit 57d7f7f8b5
6 changed files with 9 additions and 7 deletions

View File

@ -407,7 +407,7 @@ auth_attempt_failed(RemoteAddress, Username, Protocol) ->
update_auth_attempt(RemoteAddress, Username, Protocol, Incr) -> update_auth_attempt(RemoteAddress, Username, Protocol, Incr) ->
%% It should default to false as per ip/user metrics could keep growing indefinitely %% It should default to false as per ip/user metrics could keep growing indefinitely
%% It's up to the operator to enable them, and reset it required %% It's up to the operator to enable them, and reset it required
case application:get_env(rabbit, track_auth_attempt_source) of _ = case application:get_env(rabbit, track_auth_attempt_source) of
{ok, true} -> {ok, true} ->
case {RemoteAddress, Username} of case {RemoteAddress, Username} of
{<<>>, <<>>} -> {<<>>, <<>>} ->

View File

@ -11,7 +11,7 @@
-export([to_atom/2, atomize_keys/1, to_list_of_binaries/1]). -export([to_atom/2, atomize_keys/1, to_list_of_binaries/1]).
-export([to_utf8_binary/1, to_unicode_charlist/1]). -export([to_utf8_binary/1, to_unicode_charlist/1]).
-spec to_binary(Val :: binary() | list() | atom() | integer()) -> binary(). -spec to_binary(Val :: binary() | list() | atom() | integer() | function()) -> binary().
to_binary(Val) when is_list(Val) -> list_to_binary(Val); to_binary(Val) when is_list(Val) -> list_to_binary(Val);
to_binary(Val) when is_atom(Val) -> atom_to_binary(Val, utf8); to_binary(Val) when is_atom(Val) -> atom_to_binary(Val, utf8);
to_binary(Val) when is_integer(Val) -> integer_to_binary(Val); to_binary(Val) when is_integer(Val) -> integer_to_binary(Val);

View File

@ -32,7 +32,7 @@ is_in_the_past({_Y, _M, _D} = Date) ->
DateInDays < TodayInDays. DateInDays < TodayInDays.
-spec parse_duration(string()) -> datetime_plist(). -spec parse_duration(string()) -> {ok, datetime_plist()} | error.
parse_duration(Bin) parse_duration(Bin)
when is_binary(Bin) -> %TODO extended format when is_binary(Bin) -> %TODO extended format
parse_duration(binary_to_list(Bin)); parse_duration(binary_to_list(Bin));

View File

@ -2114,7 +2114,7 @@ is_rabbitmq_loaded_on_remote_node(
maybe_stop_dist_for_remote_query( maybe_stop_dist_for_remote_query(
#{dist_started_for_remote_query := true} = Context) -> #{dist_started_for_remote_query := true} = Context) ->
net_kernel:stop(), _ = net_kernel:stop(),
maps:remove(dist_started_for_remote_query, Context); maps:remove(dist_started_for_remote_query, Context);
maybe_stop_dist_for_remote_query(Context) -> maybe_stop_dist_for_remote_query(Context) ->
Context. Context.

View File

@ -47,9 +47,11 @@ encode(Term, Opts) ->
%% Fixup for JSON encoding %% Fixup for JSON encoding
%% * Transforms any Funs into strings %% * Transforms any Funs into strings
%% See rabbit_mgmt_format:format_nulls/1 %% See rabbit_mgmt_format:format_nulls/1
F = fun(V) when is_function(V) -> F = fun
(V) when is_function(V) ->
rabbit_data_coercion:to_binary(V); rabbit_data_coercion:to_binary(V);
(V) -> V (V) ->
V
end, end,
thoas:encode(fixup_terms(Term, F), Opts). thoas:encode(fixup_terms(Term, F), Opts).

View File

@ -361,7 +361,7 @@ internal_send_command_async(MethodRecord, Content,
writer_gc_threshold = GCThreshold}) -> writer_gc_threshold = GCThreshold}) ->
Frames = assemble_frames(Channel, MethodRecord, Content, FrameMax, Frames = assemble_frames(Channel, MethodRecord, Content, FrameMax,
Protocol), Protocol),
maybe_gc_large_msg(Content, GCThreshold), _ = maybe_gc_large_msg(Content, GCThreshold),
maybe_flush(State#wstate{pending = [Frames | Pending]}). maybe_flush(State#wstate{pending = [Frames | Pending]}).
%% When the amount of protocol method data buffered exceeds %% When the amount of protocol method data buffered exceeds