MobDev.Plugin.Report (mob_dev v0.5.15)

Copy Markdown View Source

Pure transforms behind mix mob.plugins: turn discovered deps + the activation list into report rows, and render them as a table.

Kept separate from the Mix task (which does the filesystem/config I/O) so the classification and formatting are unit-testable without a project on disk.

Summary

Types

An app and its loaded manifest (nil = no manifest / tier 0).

One row of mix mob.plugins output.

Vetting summary attached to a row by with_vetting/2.

Functions

Renders rows as a human-readable table (or a friendly empty message).

Renders the output of MobDev.Plugin.Audit.audit_plugin/2 (one or more) for mix mob.audit_plugins. Pure.

Builds sorted report rows from all deps and the activated-plugin list.

Adds a :vetting summary to each activated row by running the static-analysis audit (MobDev.Plugin.Audit.audit_plugin/2) and the capability checks (MobDev.Plugin.Validator.activated_capability_errors/1) over the plugin's source tree.

Types

dep()

@type dep() :: {atom(), map() | nil}

An app and its loaded manifest (nil = no manifest / tier 0).

row()

@type row() :: %{
  name: atom(),
  tier: 0..4,
  hot_pushable: true | false | :partial,
  status: :activated | :installed,
  manifest?: boolean(),
  description: String.t() | nil,
  vetting: vetting() | nil
}

One row of mix mob.plugins output.

vetting()

@type vetting() :: %{
  audit: %{
    high: non_neg_integer(),
    medium: non_neg_integer(),
    low: non_neg_integer()
  },
  capability_errors: non_neg_integer()
}

Vetting summary attached to a row by with_vetting/2.

Functions

render(rows)

@spec render([row()]) :: String.t()

Renders rows as a human-readable table (or a friendly empty message).

render_audit(reports)

@spec render_audit([map()]) :: String.t()

Renders the output of MobDev.Plugin.Audit.audit_plugin/2 (one or more) for mix mob.audit_plugins. Pure.

reports is a list of MobDev.Plugin.Audit.report() maps. Output is ordered by plugin name; findings within a plugin are already sorted by severity → file → line by audit_plugin/2. A trailing summary line tallies every severity across all reports.

rows(deps, activated)

@spec rows([dep()], [atom()]) :: [row()]

Builds sorted report rows from all deps and the activated-plugin list.

A dep is a plugin row if it ships a manifest or is named in config :mob, :plugins. A tier-0 plugin (no manifest) therefore only appears once activated — otherwise it's indistinguishable from an ordinary library dependency. Status is :activated when in the list, else :installed (present in deps, not yet activated).

with_vetting(rows, dep_dirs)

@spec with_vetting([row()], %{required(atom()) => Path.t()}) :: [row()]

Adds a :vetting summary to each activated row by running the static-analysis audit (MobDev.Plugin.Audit.audit_plugin/2) and the capability checks (MobDev.Plugin.Validator.activated_capability_errors/1) over the plugin's source tree.

dep_dirs is a map of plugin_name => plugin_dir (absolute path). Rows whose plugin is not in dep_dirs (or which are :installed only — not activated) get vetting: nil and render as a dash. This function performs IO; pure rendering stays in render/1.