Bonfire.Common.ModuleAnalyzer (Bonfire v0.9.12-social-beta.70)

View Source

Common functionality for analyzing the codebase.

This module provides the core functionality for scanning and analyzing modules across Bonfire applications, serving as a foundation for both the ExtensionBehaviour registry and the ConfigSettingsRegistry.

Summary

Functions

Get all modules from Bonfire-related applications.

Get all Bonfire-related applications based on name pattern.

Extract module info based on a custom extractor function.

Filter modules based on a predicate function.

Check if a module uses a particular module (via import, alias, or direct calls).

Flatten a hierarchical structure into a list.

Helper to run a GenServer that populates a persistent term cache.

Functions

app_modules_to_scan(opts \\ [])

Get all modules from Bonfire-related applications.

Returns a list of tuples {app_name, [module_list]}

apps_to_scan(opts \\ [])

Get all Bonfire-related applications based on name pattern.

extract_from_modules(modules, extractor)

Extract module info based on a custom extractor function.

The extractor should be a function that takes a module and returns a list of extracted data items or an empty list if nothing is found.

filter_modules(app_modules, predicate)

Filter modules based on a predicate function.

The predicate should be a function that takes a module and returns true/false.

module_uses_module?(module, target_module)

Check if a module uses a particular module (via import, alias, or direct calls).

This implementation analyzes the module's abstract code to detect imports, aliases, and module references.

modules_only(app_modules)

Flatten a hierarchical structure into a list.

populate_registry(module, prepare_fun)

Helper to run a GenServer that populates a persistent term cache.

This is a common pattern for both registries.