ExDNA.Refactor.MacroSuggestion (ExDNA v1.5.1)

Copy Markdown View Source

Detects clone groups that should be refactored into macros rather than functions.

A macro is suggested when a clone group has 3+ fragments that are all module-level constructs (not inside a def) and contain struct literals or DSL calls like field :name, :string or pipe_through [:browser].

Summary

Functions

Returns true if the clone group qualifies for a macro extraction suggestion.

Generate a macro name from a clone's fragments.

Functions

macro_candidate?(clone)

@spec macro_candidate?(ExDNA.Detection.Clone.t()) :: boolean()

Returns true if the clone group qualifies for a macro extraction suggestion.

macro_name(clone)

@spec macro_name(ExDNA.Detection.Clone.t()) :: String.t()

Generate a macro name from a clone's fragments.