mix ex_dna (ExDNA v1.5.1)

Copy Markdown View Source

Scans your project for duplicated code blocks using AST analysis.

$ mix ex_dna
$ mix ex_dna lib/my_app/accounts
$ mix ex_dna --min-mass 20 --literal-mode abstract
$ mix ex_dna --min-similarity 0.85

Command-line options

  • --min-mass — minimum AST node count (default: 30)
  • --min-occurrences — minimum number of code occurrences to report a clone (default: 2)
  • --min-similarity — similarity threshold 0.0–1.0 (default: 1.0). Values below 1.0 enable Type-III near-miss detection.
  • --max-window-size — max consecutive sibling functions combined into a single fingerprint (default: 4). Raise to catch larger cross-module clones.
  • --mass-tolerance — max relative size difference for Type-III comparison, 0.0–1.0 (default: 0.3). Raise to compare fragments of more different sizes.
  • --literal-modekeep (Type-I only) or abstract (also Type-II). Default: keep
  • --normalize-pipes — treat x |> f() the same as f(x). Default: false
  • --exclude-macro — macro name to skip during analysis (repeatable). Common: schema, pipe_through, plug
  • --ignore-attribute — additional attribute name to ignore (repeatable). Documentation/type attributes (moduledoc, doc, type, spec, etc.) are ignored by default. Use this for project-specific noise.
  • --ignore — glob pattern to exclude (repeatable)
  • --format — output format: console (default), json, html, or sarif
  • --max-clones — maximum allowed clones. Exits with code 1 only when exceeded. Useful for gradual adoption in brownfield projects.

Exits with code 1 if clones are found (or exceed --max-clones).