Skip to content

Commit c5474ce

Browse files
authored
no_macros now allows for logger default macros (?LOG, ?LOG_... and friends) (#338)
* Update list of epp predefined macros * Allow for logger macros (?LOG_... and friends) by default
1 parent 59861d4 commit c5474ce

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/elvis_style.erl

+16-2
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ check_no_macro_calls(Calls) ->
396396
[elvis_result:item()].
397397
no_macros(ElvisConfig, RuleTarget, RuleConfig) ->
398398
TreeRootNode = get_root(ElvisConfig, RuleTarget, RuleConfig),
399-
AllowedMacros = maps:get(allow, RuleConfig, []) ++ eep_predef_macros(),
399+
AllowedMacros = maps:get(allow, RuleConfig, []) ++ eep_predef_macros() ++ logger_macros(),
400400

401401
MacroNodes =
402402
elvis_code:find(fun is_macro_node/1, TreeRootNode, #{traverse => all, mode => node}),
@@ -478,10 +478,12 @@ is_begin_node(Node) ->
478478
ktn_code:type(Node) =:= 'begin'.
479479

480480
eep_predef_macros() ->
481-
% From unexported eep:predef_macros/1
481+
% From unexported epp:predef_macros/1
482482
['BASE_MODULE',
483483
'BASE_MODULE_STRING',
484484
'BEAM',
485+
'FEATURE_AVAILABLE',
486+
'FEATURE_ENABLED',
485487
'FILE',
486488
'FUNCTION_ARITY',
487489
'FUNCTION_NAME',
@@ -491,6 +493,18 @@ eep_predef_macros() ->
491493
'MODULE_STRING',
492494
'OTP_RELEASE'].
493495

496+
logger_macros() ->
497+
% From logger.hrl
498+
['LOG',
499+
'LOG_ALERT',
500+
'LOG_CRITICAL',
501+
'LOG_DEBUG',
502+
'LOG_EMERGENCY',
503+
'LOG_ERROR',
504+
'LOG_INFO',
505+
'LOG_NOTICE',
506+
'LOG_WARNING'].
507+
494508
-type no_space_after_pound_config() :: #{ignore => [ignorable()]}.
495509

496510
-spec no_space_after_pound(elvis_config:config(),

0 commit comments

Comments
 (0)