From 38cc3ccb1e5cd094a93af6e649ee4be16dedc684 Mon Sep 17 00:00:00 2001 From: Badlop Date: Thu, 5 Jun 2025 16:38:29 +0200 Subject: [PATCH] Avoid using the "else" conditional compilation macro directive Even if "-else." is a valid directive: https://www.erlang.org/docs/28/system/macros.html#conditional-compilation there is a bug in rebar3_format that annoyingly rewrites it as "- else ." https://github.com/AdRoll/rebar3_format/issues/337 as a quick workaround, rewrite directives to not use "-else." --- src/ejabberd_web_admin.erl | 4 +++- src/mod_adhoc_api.erl | 4 +++- test/json_test.erl | 10 +++++++--- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/ejabberd_web_admin.erl b/src/ejabberd_web_admin.erl index 42ca212c0..0e122d451 100644 --- a/src/ejabberd_web_admin.erl +++ b/src/ejabberd_web_admin.erl @@ -1925,7 +1925,9 @@ lists_zipwith3(Combine, [E1 | List1], [E2 | List2], [], DefX, DefY, DefZ, Res) - E123 = Combine(E1, E2, DefZ), lists_zipwith3(Combine, List1, List2, [], DefX, DefY, DefZ, [E123 | Res]). --else. +-endif. + +-ifndef(OTP_BELOW_26). lists_zipwith3(Combine, List1, List2, List3, How) -> lists:zipwith3(Combine, List1, List2, List3, How). diff --git a/src/mod_adhoc_api.erl b/src/mod_adhoc_api.erl index 2e478333c..59a4b4b5f 100644 --- a/src/mod_adhoc_api.erl +++ b/src/mod_adhoc_api.erl @@ -664,7 +664,9 @@ lists_zip3_pad([A | As], Nil, Nil, Xs) when (Nil == none) or (Nil == []) -> lists_zip3_pad([], Nil, Nil, Xs) when (Nil == none) or (Nil == []) -> lists:reverse(Xs). --else. +-endif. + +-ifndef(OTP_BELOW_26). lists_zip3_pad(As, Bs, Cs) -> lists:zip3(As, Bs, Cs, {pad, {error_missing_args_def, "", ""}}). diff --git a/test/json_test.erl b/test/json_test.erl index 49fad0f25..7f16cf7a7 100644 --- a/test/json_test.erl +++ b/test/json_test.erl @@ -11,7 +11,6 @@ encode_binary_test() -> Encoded = <<"\"This is an error text.\"">>, ?assertMatch(Encoded, misc:json_encode(Binary)). --ifdef(OTP_BELOW_27). -ifdef(OTP_BELOW_26). %% OTP 25 or lower @@ -24,7 +23,11 @@ encode_map_test() -> <<"{\"service\":\"conference\",\"name\":\"room\",\"jid\":\"user@server\",\"affiliation\":\"member\"}">>, ?assertMatch(Encoded, misc:json_encode(Map)). --else. +-endif. + +-ifdef(OTP_BELOW_27). + +-ifndef(OTP_BELOW_26). %% OTP 26 encode_map_test() -> @@ -37,8 +40,9 @@ encode_map_test() -> ?assertMatch(Encoded, misc:json_encode(Map)). -endif. +-endif. --else. +-ifndef(OTP_BELOW_27). %% OTP 27 or higher or higher encode_map_test() ->