ExDNA.Config (ExDNA v1.5.2)

Copy Markdown View Source

Configuration for ExDNA.

Options can be provided in three layers (later wins):

  1. Built-in defaults
  2. .ex_dna.exs config file in the project root
  3. Keyword options passed to ExDNA.analyze/1 or CLI flags

Config file

Create .ex_dna.exs in your project root:

%{
  min_mass: 25,
  min_occurrences: 3,
  ignore: ["lib/my_app_web/templates/**"],
  excluded_macros: [:schema, :pipe_through, :plug],
  normalize_pipes: true
}

The file is evaluated with Code.eval_file/1 and must return a map.

Advanced tuning

  • :max_window_size — maximum number of consecutive sibling functions combined into a single fingerprint for cross-module clone detection. Higher values catch clones spanning more adjacent functions at the cost of more fragments to compare. Must be ≥ 2. Default: 4.

  • :mass_tolerance — maximum relative size difference allowed between two fragments for Type-III (fuzzy) comparison. A value of 0.3 means fragments are compared only if the smaller is at least 70% the size of the larger. Raise toward 0.5 to catch clones between thin wrappers and fat implementations. Must be in (0.0, 1.0]. Default: 0.3.

Summary

Types

literal_mode()

@type literal_mode() :: :keep | :abstract

t()

@type t() :: %ExDNA.Config{
  excluded_macros: [atom()],
  ignore: [String.t()],
  ignored_attributes: [atom()],
  literal_mode: literal_mode(),
  mass_tolerance: float(),
  max_window_size: pos_integer(),
  min_mass: pos_integer(),
  min_occurrences: pos_integer(),
  min_similarity: float(),
  normalize_pipes: boolean(),
  parse_timeout: pos_integer(),
  paths: [String.t()],
  reporters: [module()]
}

Functions

default(key)

@spec default(atom()) :: term()

new(opts)

@spec new(keyword()) :: t()