You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am getting ABC errors for defmacro deriving calls, it appears that the logic does not exclude the method declarations themselves only calls within logic to other methods.
A crude patch like the following addressing the issue but this needs to be thought out to avoid headaches with existing users. Possibly a new param is needed? There is already a similiar ex ception above line L73 for :using macros.
forop<-@def_opsdodefptraverse({unquote(op),meta,arguments}=ast,issues,issue_meta,max_abc_size,excluded_functions)whenis_list(arguments)do# Exclude declarations of methods included in excluded_function list.with[{f,_,_}|_]<-arguments,true<-is_atom(f),true<-Enum.member?(excluded_functions,Atom.to_string(f))do{ast,issues}else_->abc_size=ast|>abc_size_for(excluded_functions)|>roundifabc_size>max_abc_sizedofun_name=Credo.Code.Module.def_name(ast){ast,[issue_for(issue_meta,meta[:line],fun_name,max_abc_size,abc_size)|issues]}else{ast,issues}endendendend
Additionally this might be faster with
defp traverse(
{op, meta, arguments} = ast,
issues,
issue_meta,
max_abc_size,
excluded_functions
)
when is_list(arguments) and op in @def_ops do
to reduce the amount of generated code while replacing with guard checks. (although we'd have to run benchee to verify).
The text was updated successfully, but these errors were encountered:
I am getting ABC errors for defmacro deriving calls, it appears that the logic does not exclude the method declarations themselves only calls within logic to other methods.
https://github.com/rrrene/credo/blob/master/lib/credo/check/refactor/abc_size.ex#L73-L99
A crude patch like the following addressing the issue but this needs to be thought out to avoid headaches with existing users. Possibly a new param is needed? There is already a similiar ex ception above line L73 for :using macros.
Additionally this might be faster with
to reduce the amount of generated code while replacing with guard checks. (although we'd have to run benchee to verify).
The text was updated successfully, but these errors were encountered: