Ragex.Analysis.Cohesion (Ragex v0.21.0)

View Source

Language-agnostic Cohesion analysis for modules (functional) and classes (OOP).

Computes structural cohesion using internal method/function call graphs:

  • Functional Cohesion Index (FCI): 1.0 / number_of_connected_components.
  • Tight Cohesion (TCC): connected_pairs / total_possible_pairs.

Summary

Functions

Analyzes cohesion for all modules in a directory.

Analyzes cohesion for a specific module by name.

Types

cohesion_result()

@type cohesion_result() :: %{
  module: atom(),
  file: String.t(),
  language: atom(),
  cohesion_score: float(),
  tight_cohesion: float(),
  components_count: non_neg_integer(),
  functional_cohesion_index: float(),
  functions_count: non_neg_integer(),
  components: [[tuple()]]
}

Functions

analyze_directory(dir_path)

@spec analyze_directory(String.t()) :: {:ok, [cohesion_result()]} | {:error, term()}

Analyzes cohesion for all modules in a directory.

analyze_module(module_name)

@spec analyze_module(atom()) :: {:ok, cohesion_result()} | {:error, term()}

Analyzes cohesion for a specific module by name.