fix(emqx_plugins, emqx_sys, emqx_sys_mon, emqx_ws_connection): Dialyzer warnings

This commit is contained in:
ayodele.akingbule 2020-11-13 00:33:49 +01:00 committed by Zaiming Shi
parent 39883bdab1
commit 18ae158f45
4 changed files with 27 additions and 27 deletions

View File

@ -65,7 +65,7 @@ load() ->
case emqx:get_env(plugins_loaded_file) of case emqx:get_env(plugins_loaded_file) of
undefined -> ignore; %% No plugins available undefined -> ignore; %% No plugins available
File -> File ->
ensure_file(File), _ = ensure_file(File),
with_loaded_file(File, fun(Names) -> load_plugins(Names, false) end) with_loaded_file(File, fun(Names) -> load_plugins(Names, false) end)
end. end.
@ -165,7 +165,7 @@ load_expand_plugins() ->
load_expand_plugin(PluginDir) -> load_expand_plugin(PluginDir) ->
init_expand_plugin_config(PluginDir), init_expand_plugin_config(PluginDir),
Ebin = filename:join([PluginDir, "ebin"]), Ebin = filename:join([PluginDir, "ebin"]),
code:add_patha(Ebin), _ = code:add_patha(Ebin),
Modules = filelib:wildcard(filename:join([Ebin, "*.beam"])), Modules = filelib:wildcard(filename:join([Ebin, "*.beam"])),
lists:foreach(fun(Mod) -> lists:foreach(fun(Mod) ->
Module = list_to_atom(filename:basename(Mod, ".beam")), Module = list_to_atom(filename:basename(Mod, ".beam")),
@ -246,7 +246,7 @@ apply_configs([{App, Config} | More]) ->
%% Stop plugins %% Stop plugins
stop_plugins(Names) -> stop_plugins(Names) ->
[stop_app(App) || App <- Names], _ = [stop_app(App) || App <- Names],
ok. ok.
plugin(AppName, Type) -> plugin(AppName, Type) ->
@ -297,7 +297,7 @@ start_app(App, SuccFun) ->
unload_plugin(App, Persistent) -> unload_plugin(App, Persistent) ->
case stop_app(App) of case stop_app(App) of
ok -> ok ->
plugin_unloaded(App, Persistent), ok; _ = plugin_unloaded(App, Persistent), ok;
{error, Reason} -> {error, Reason} ->
{error, Reason} {error, Reason}
end. end.

View File

@ -151,16 +151,16 @@ handle_cast(Msg, State) ->
{noreply, State}. {noreply, State}.
handle_info({timeout, TRef, heartbeat}, State = #state{heartbeat = TRef}) -> handle_info({timeout, TRef, heartbeat}, State = #state{heartbeat = TRef}) ->
publish(uptime, iolist_to_binary(uptime(State))), _ = publish(uptime, iolist_to_binary(uptime(State))),
publish(datetime, iolist_to_binary(datetime())), _ = publish(datetime, iolist_to_binary(datetime())),
{noreply, heartbeat(State)}; {noreply, heartbeat(State)};
handle_info({timeout, TRef, tick}, State = #state{ticker = TRef, version = Version, sysdescr = Descr}) -> handle_info({timeout, TRef, tick}, State = #state{ticker = TRef, version = Version, sysdescr = Descr}) ->
publish(version, Version), _ = publish(version, Version),
publish(sysdescr, Descr), _ = publish(sysdescr, Descr),
publish(brokers, ekka_mnesia:running_nodes()), _ = publish(brokers, ekka_mnesia:running_nodes()),
publish(stats, emqx_stats:getstats()), _ = publish(stats, emqx_stats:getstats()),
publish(metrics, emqx_metrics:all()), _ = publish(metrics, emqx_metrics:all()),
{noreply, tick(State), hibernate}; {noreply, tick(State), hibernate};
handle_info(Info, State) -> handle_info(Info, State) ->

View File

@ -55,7 +55,7 @@ start_link(Opts) ->
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
init([Opts]) -> init([Opts]) ->
erlang:system_monitor(self(), parse_opt(Opts)), _ = erlang:system_monitor(self(), parse_opt(Opts)),
emqx_logger:set_proc_metadata(#{sysmon => true}), emqx_logger:set_proc_metadata(#{sysmon => true}),
%% Monitor cluster partition event %% Monitor cluster partition event
@ -174,7 +174,7 @@ suppress(Key, SuccFun, State = #{events := Events}) ->
true -> true ->
{noreply, State}; {noreply, State};
false -> false ->
SuccFun(), _ = SuccFun(),
{noreply, State#{events := [Key|Events]}} {noreply, State#{events := [Key|Events]}}
end. end.

View File

@ -63,7 +63,7 @@
%% Simulate the active_n opt %% Simulate the active_n opt
active_n :: pos_integer(), active_n :: pos_integer(),
%% MQTT Piggyback %% MQTT Piggyback
mqtt_piggyback :: single | multiple, mqtt_piggyback :: single | multiple,
%% Limiter %% Limiter
limiter :: maybe(emqx_limiter:limiter()), limiter :: maybe(emqx_limiter:limiter()),
%% Limit Timer %% Limit Timer
@ -535,7 +535,7 @@ handle_outgoing(Packets, State = #state{active_n = ActiveN, mqtt_piggyback = MQT
postpone({check_gc, Stats}, State); postpone({check_gc, Stats}, State);
false -> State false -> State
end, end,
{case MQTTPiggyback of {case MQTTPiggyback of
single -> [{binary, IoData}]; single -> [{binary, IoData}];
multiple -> lists:map(fun(Bin) -> {binary, Bin} end, IoData) multiple -> lists:map(fun(Bin) -> {binary, Bin} end, IoData)
@ -568,33 +568,33 @@ serialize_and_inc_stats_fun(#state{serialize = Serialize}) ->
]}). ]}).
inc_recv_stats(Cnt, Oct) -> inc_recv_stats(Cnt, Oct) ->
emqx_pd:inc_counter(incoming_bytes, Oct), _ = emqx_pd:inc_counter(incoming_bytes, Oct),
emqx_pd:inc_counter(recv_cnt, Cnt), _ = emqx_pd:inc_counter(recv_cnt, Cnt),
emqx_pd:inc_counter(recv_oct, Oct), _ = emqx_pd:inc_counter(recv_oct, Oct),
emqx_metrics:inc('bytes.received', Oct). emqx_metrics:inc('bytes.received', Oct).
inc_incoming_stats(Packet = ?PACKET(Type)) -> inc_incoming_stats(Packet = ?PACKET(Type)) ->
emqx_pd:inc_counter(recv_pkt, 1), _ = emqx_pd:inc_counter(recv_pkt, 1),
if Type == ?PUBLISH -> if Type == ?PUBLISH ->
emqx_pd:inc_counter(recv_msg, 1), _ = emqx_pd:inc_counter(recv_msg, 1),
emqx_pd:inc_counter(incoming_pubs, 1); _ = emqx_pd:inc_counter(incoming_pubs, 1);
true -> ok true -> ok
end, end,
emqx_metrics:inc_recv(Packet). emqx_metrics:inc_recv(Packet).
inc_outgoing_stats(Packet = ?PACKET(Type)) -> inc_outgoing_stats(Packet = ?PACKET(Type)) ->
emqx_pd:inc_counter(send_pkt, 1), _ = emqx_pd:inc_counter(send_pkt, 1),
if Type == ?PUBLISH -> if Type == ?PUBLISH ->
emqx_pd:inc_counter(send_msg, 1), _ = emqx_pd:inc_counter(send_msg, 1),
emqx_pd:inc_counter(outgoing_pubs, 1); _ = emqx_pd:inc_counter(outgoing_pubs, 1);
true -> ok true -> ok
end, end,
emqx_metrics:inc_sent(Packet). emqx_metrics:inc_sent(Packet).
inc_sent_stats(Cnt, Oct) -> inc_sent_stats(Cnt, Oct) ->
emqx_pd:inc_counter(outgoing_bytes, Oct), _ = emqx_pd:inc_counter(outgoing_bytes, Oct),
emqx_pd:inc_counter(send_cnt, Cnt), _ = emqx_pd:inc_counter(send_cnt, Cnt),
emqx_pd:inc_counter(send_oct, Oct), _ = emqx_pd:inc_counter(send_oct, Oct),
emqx_metrics:inc('bytes.sent', Oct). emqx_metrics:inc('bytes.sent', Oct).
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------