From ff55b0ff457174166619eca75e80e3a3420549f8 Mon Sep 17 00:00:00 2001 From: Zaiming Shi Date: Mon, 9 Nov 2020 22:53:12 +0100 Subject: [PATCH] fix(emqx_rule_runtime): Dialyzer warnings --- apps/emqx_rule_engine/src/emqx_rule_runtime.erl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/apps/emqx_rule_engine/src/emqx_rule_runtime.erl b/apps/emqx_rule_engine/src/emqx_rule_runtime.erl index 2098072d3..808cccb99 100644 --- a/apps/emqx_rule_engine/src/emqx_rule_runtime.erl +++ b/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) ->