소스 검색

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

ayodele.akingbule 5 년 전
부모
커밋
18ae158f45
4개의 변경된 파일27개의 추가작업 그리고 27개의 파일을 삭제
  1. 4 4
      src/emqx_plugins.erl
  2. 7 7
      src/emqx_sys.erl
  3. 2 2
      src/emqx_sys_mon.erl
  4. 14 14
      src/emqx_ws_connection.erl

+ 4 - 4
src/emqx_plugins.erl

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

+ 7 - 7
src/emqx_sys.erl

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

+ 2 - 2
src/emqx_sys_mon.erl

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

+ 14 - 14
src/emqx_ws_connection.erl

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