Presubmit.Source.Diff (presubmit v0.2.2)

Copy Markdown View Source

The structural difference between the Elixir source before and after a change set: modules and functions added, removed, renamed, or changed.

Computed by set difference over Presubmit.Source.Facts for every changed .ex/.exs file. A module that disappears under one name and reappears under another with the same public functions is reported as a rename rather than a removal plus an addition.

Summary

Functions

Whether any function body changed, or any function was added or removed.

Computes the structural diff for every Elixir file changed by commit.

API functions (public, not @doc false) added, as {module, name, arity}.

Whether any API function was added or removed.

API functions (public, not @doc false) removed, as {module, name, arity}.

Types

module_pair()

t()

@type t() :: %Presubmit.Source.Diff{
  functions: %{
    added: [Presubmit.Source.Facts.Function.t()],
    removed: [Presubmit.Source.Facts.Function.t()],
    body_changed: [
      {Presubmit.Source.Facts.Function.t(), Presubmit.Source.Facts.Function.t()}
    ],
    spec_added: [Presubmit.Source.Facts.Function.t()],
    spec_removed: [Presubmit.Source.Facts.Function.t()]
  },
  modules: %{
    added: [Presubmit.Source.Facts.Module.t()],
    removed: [Presubmit.Source.Facts.Module.t()],
    renamed: [module_pair()],
    modified: [module_pair()]
  },
  structs: %{
    fields_added: [{module(), atom()}],
    fields_removed: [{module(), atom()}]
  },
  unparsed: [{String.t(), term()}]
}

Functions

behaviour_changed?(diff)

@spec behaviour_changed?(t()) :: boolean()

Whether any function body changed, or any function was added or removed.

compute(commit)

@spec compute(Presubmit.Commit.t()) :: t()

Computes the structural diff for every Elixir file changed by commit.

public_added(diff)

@spec public_added(t()) :: [{module(), atom(), arity()}]

API functions (public, not @doc false) added, as {module, name, arity}.

public_api_changed?(diff)

@spec public_api_changed?(t()) :: boolean()

Whether any API function was added or removed.

public_removed(diff)

@spec public_removed(t()) :: [{module(), atom(), arity()}]

API functions (public, not @doc false) removed, as {module, name, arity}.