Detects clone groups where the same function is implemented identically across multiple modules, suggesting a behaviour extraction.
A behaviour is suggested when 2+ clones have fragments from different
modules, and each fragment is a def with the same function name and arity.
Summary
Functions
Analyze a list of clones and attach behaviour suggestions where appropriate.
Generate a behaviour suggestion for a single clone, or nil.
Types
@type t() :: %ExDNA.Refactor.BehaviourSuggestion{ callback_arity: non_neg_integer(), callback_name: atom(), modules: [String.t()] }
Functions
@spec analyze([ExDNA.Detection.Clone.t()], %{required(String.t()) => Macro.t()}) :: [ ExDNA.Detection.Clone.t() ]
Analyze a list of clones and attach behaviour suggestions where appropriate.
Accepts an optional map of %{file_path => ast} to resolve module names
without re-reading files from disk.
@spec suggest(ExDNA.Detection.Clone.t(), %{required(String.t()) => Macro.t()}) :: t() | nil
Generate a behaviour suggestion for a single clone, or nil.