From 76df6b3bcbe150ddbd7df23cf0bd061fc1032ed5 Mon Sep 17 00:00:00 2001 From: "Paulo F. Oliveira" Date: Wed, 28 Feb 2024 13:29:25 +0000 Subject: [PATCH 1/2] Update list of epp predefined macros --- src/elvis_style.erl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/elvis_style.erl b/src/elvis_style.erl index d474cde..3dc26d4 100644 --- a/src/elvis_style.erl +++ b/src/elvis_style.erl @@ -478,10 +478,12 @@ is_begin_node(Node) -> ktn_code:type(Node) =:= 'begin'. eep_predef_macros() -> - % From unexported eep:predef_macros/1 + % From unexported epp:predef_macros/1 ['BASE_MODULE', 'BASE_MODULE_STRING', 'BEAM', + 'FEATURE_AVAILABLE', + 'FEATURE_ENABLED', 'FILE', 'FUNCTION_ARITY', 'FUNCTION_NAME', From c413147d1b4c759681e425a0d1a8b33998ff5279 Mon Sep 17 00:00:00 2001 From: "Paulo F. Oliveira" Date: Wed, 28 Feb 2024 13:29:42 +0000 Subject: [PATCH 2/2] Allow for logger macros (?LOG_... and friends) by default --- src/elvis_style.erl | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/elvis_style.erl b/src/elvis_style.erl index 3dc26d4..1987c88 100644 --- a/src/elvis_style.erl +++ b/src/elvis_style.erl @@ -396,7 +396,7 @@ check_no_macro_calls(Calls) -> [elvis_result:item()]. no_macros(ElvisConfig, RuleTarget, RuleConfig) -> TreeRootNode = get_root(ElvisConfig, RuleTarget, RuleConfig), - AllowedMacros = maps:get(allow, RuleConfig, []) ++ eep_predef_macros(), + AllowedMacros = maps:get(allow, RuleConfig, []) ++ eep_predef_macros() ++ logger_macros(), MacroNodes = elvis_code:find(fun is_macro_node/1, TreeRootNode, #{traverse => all, mode => node}), @@ -493,6 +493,18 @@ eep_predef_macros() -> 'MODULE_STRING', 'OTP_RELEASE']. +logger_macros() -> + % From logger.hrl + ['LOG', + 'LOG_ALERT', + 'LOG_CRITICAL', + 'LOG_DEBUG', + 'LOG_EMERGENCY', + 'LOG_ERROR', + 'LOG_INFO', + 'LOG_NOTICE', + 'LOG_WARNING']. + -type no_space_after_pound_config() :: #{ignore => [ignorable()]}. -spec no_space_after_pound(elvis_config:config(),