Ragex.Analysis.Runner (Ragex v0.14.1)

View Source

Shared analysis runner logic used by both Mix tasks and MCP tools.

Extracts the "run all analyses" pipeline so that:

  • mix ragex.analyze can run it locally
  • The comprehensive_analyze MCP tool can run it on the server
  • Mix tasks can delegate to the running server via MCP without starting a second BEAM VM

Summary

Functions

Analyzes a directory and populates the knowledge graph.

Runs all enabled analyses based on the config.

Types

analyze_result()

@type analyze_result() :: %{
  files_analyzed: non_neg_integer(),
  entities_found: non_neg_integer(),
  errors: list()
}

config()

@type config() :: %{
  :path => String.t(),
  :severity => [atom()],
  :threshold => float(),
  :min_complexity => integer(),
  :god_threshold => integer(),
  :instability_threshold => float(),
  :analyses => %{required(atom()) => boolean()},
  optional(atom()) => term()
}

Functions

analyze_directory(path, opts \\ [])

@spec analyze_directory(
  String.t(),
  keyword()
) :: {:ok, analyze_result()} | {:error, term()}

Analyzes a directory and populates the knowledge graph.

Returns {:ok, analyze_result} or {:error, reason}.

run_all(config)

@spec run_all(config()) :: map()

Runs all enabled analyses based on the config.

Returns a map of %{analysis_type => result} matching the format expected by Mix.Tasks.Ragex.Analyze formatters.