ExDNA.Detection.Clone (ExDNA v1.5.0)

Copy Markdown View Source

Represents a detected code clone — a group of structurally identical fragments.

Summary

Functions

Build a clone from a group of matching fragments.

Types

clone_type()

@type clone_type() :: :type_i | :type_ii | :type_iii

fragment_location()

@type fragment_location() :: %{
  file: String.t(),
  line: pos_integer(),
  ast: Macro.t(),
  mass: pos_integer()
}

t()

@type t() :: %ExDNA.Detection.Clone{
  behaviour_suggestion: map() | nil,
  fragments: [fragment_location()],
  hash: binary() | nil,
  mass: pos_integer(),
  similarity: float() | nil,
  source_snippets: [String.t()],
  suggestion: map() | nil,
  type: clone_type()
}

Functions

from_fragments(frags, type)

@spec from_fragments([map()], clone_type()) :: t()

Build a clone from a group of matching fragments.

Source snippets are computed eagerly since every surviving clone will have them accessed by reporters and stats.