Browse Source

fix(emqx_rule_runtime): Dialyzer warnings

Zaiming Shi 5 năm trước cách đây
mục cha
commit
ff55b0ff45
1 tập tin đã thay đổi với 9 bổ sung1 xóa
  1. 9 1
      apps/emqx_rule_engine/src/emqx_rule_runtime.erl

+ 9 - 1
apps/emqx_rule_engine/src/emqx_rule_runtime.erl

@@ -49,7 +49,7 @@ apply_rules([], _Input) ->
 apply_rules([#rule{enabled = false}|More], Input) ->
     apply_rules(More, Input);
 apply_rules([Rule = #rule{id = RuleID}|More], Input) ->
-    try apply_rule(Rule, Input)
+    try apply_rule_discard_result(Rule, Input)
     catch
         %% ignore the errors if select or match failed
         _:{select_and_transform_error, Error} ->
@@ -70,6 +70,13 @@ apply_rules([Rule = #rule{id = RuleID}|More], Input) ->
     end,
     apply_rules(More, Input).
 
+apply_rule_discard_result(Rule, Input) ->
+    %% TODO check if below two clauses are ok to discard:
+    %% {'error','nomatch'}
+    %% {'ok',[any()]}
+    _ = apply_rule(Rule, Input),
+    ok.
+
 apply_rule(Rule = #rule{id = RuleID}, Input) ->
     clear_rule_payload(),
     do_apply_rule(Rule, add_metadata(Input, #{rule_id => RuleID})).
@@ -160,6 +167,7 @@ select_and_collect([Field|More], Input, {Output, LastKV}) ->
         {nested_put(Key, Val, Output), LastKV}).
 
 %% Filter each item got from FOREACH
+-dialyzer({nowarn_function, filter_collection/4}).
 filter_collection(Input, InCase, DoEach, {CollKey, CollVal}) ->
     lists:filtermap(
         fun(Item) ->