Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no_macros now allows for logger default macros (?LOG, ?LOG_... and friends) #338

Merged
merged 2 commits into from
Feb 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/elvis_style.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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}),
Expand Down Expand Up @@ -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
elbrujohalcon marked this conversation as resolved.
Show resolved Hide resolved
['BASE_MODULE',
'BASE_MODULE_STRING',
'BEAM',
'FEATURE_AVAILABLE',
'FEATURE_ENABLED',
'FILE',
'FUNCTION_ARITY',
'FUNCTION_NAME',
Expand All @@ -491,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(),
Expand Down
Loading