From 7923f017bece157ca3d6fd463ca4f998c8ac281c Mon Sep 17 00:00:00 2001 From: "Zaiming (Stone) Shi" Date: Fri, 25 Mar 2022 07:25:02 +0100 Subject: [PATCH] style(elvis): avoid using if --- .../emqx_license/src/emqx_license_resources.erl | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lib-ee/emqx_license/src/emqx_license_resources.erl b/lib-ee/emqx_license/src/emqx_license_resources.erl index e92780f55..d9ace41f0 100644 --- a/lib-ee/emqx_license/src/emqx_license_resources.erl +++ b/lib-ee/emqx_license/src/emqx_license_resources.erl @@ -84,18 +84,17 @@ connection_quota_early_alarm({ok, #{max_connections := Max}}) when is_integer(Ma Count = connection_count(), Low = emqx_conf:get([license, connection_low_watermark], 0.75), High = emqx_conf:get([license, connection_high_watermark], 0.80), - if - Count > Max * High -> + Count > Max * High andalso + begin HighPercent = float_to_binary(High * 100, [{decimals, 0}]), Message = iolist_to_binary([ "License: live connection number exceeds ", HighPercent, "%" ]), - catch emqx_alarm:activate(license_quota, #{high_watermark => HighPercent}, Message); - Count < Max * Low -> - catch emqx_alarm:deactivate(license_quota); - true -> - ok - end; + catch emqx_alarm:activate(license_quota, #{high_watermark => HighPercent}, Message) + end, + Count < Max * Low andalso + catch emqx_alarm:deactivate(license_quota), + ok; connection_quota_early_alarm(_Limits) -> ok.