.. index:: code_metric .. _code_metric/0: .. rst-class:: right **category** ``code_metric`` =============== Core predicates for computing source code metrics. | **Availability:** | ``logtalk_load(code_metrics(loader))`` | **Author:** Ebrahim Azarisooreh and Paulo Moura | **Version:** 0:12:1 | **Date:** 2024-05-08 | **Compilation flags:** | ``static`` | **Extends:** | ``public`` :ref:`code_metrics_utilities ` | ``public`` :ref:`options ` | **Uses:** | :ref:`list ` | :ref:`logtalk ` | :ref:`os ` | :ref:`type ` | **Remarks:** | (none) | **Inherited public predicates:** |  :ref:`options_protocol/0::check_option/1`  :ref:`options_protocol/0::check_options/1`  :ref:`options_protocol/0::default_option/1`  :ref:`options_protocol/0::default_options/1`  :ref:`options_protocol/0::option/2`  :ref:`options_protocol/0::option/3`  :ref:`options_protocol/0::valid_option/1`  :ref:`options_protocol/0::valid_options/1`   .. contents:: :local: :backlinks: top Public predicates ----------------- .. index:: entity/1 .. _code_metric/0::entity/1: ``entity/1`` ^^^^^^^^^^^^ Scans an entity and prints its metric score. | **Compilation flags:** | ``static`` | **Template:** | ``entity(Entity)`` | **Mode and number of proofs:** | ``entity(+term)`` - ``zero_or_one`` ------------ .. index:: file/2 .. _code_metric/0::file/2: ``file/2`` ^^^^^^^^^^ Prints metric scores for all the entities defined in a loaded source file using the given options. | **Compilation flags:** | ``static`` | **Template:** | ``file(File,Options)`` | **Mode and number of proofs:** | ``file(+atom,+list(compound))`` - ``zero_or_one`` ------------ .. index:: file/1 .. _code_metric/0::file/1: ``file/1`` ^^^^^^^^^^ Prints metric scores for all the entities defined in a loaded source file using default options. | **Compilation flags:** | ``static`` | **Template:** | ``file(File)`` | **Mode and number of proofs:** | ``file(+atom)`` - ``zero_or_one`` ------------ .. index:: directory/2 .. _code_metric/0::directory/2: ``directory/2`` ^^^^^^^^^^^^^^^ Scans a directory and prints metric scores for all entities defined in its loaded source files using the given options. | **Compilation flags:** | ``static`` | **Template:** | ``directory(Directory,Options)`` | **Mode and number of proofs:** | ``directory(+atom,+list(compound))`` - ``one`` ------------ .. index:: directory/1 .. _code_metric/0::directory/1: ``directory/1`` ^^^^^^^^^^^^^^^ Scans a directory and prints metric scores for all entities defined in its loaded source files using default options. | **Compilation flags:** | ``static`` | **Template:** | ``directory(Directory)`` | **Mode and number of proofs:** | ``directory(+atom)`` - ``one`` ------------ .. index:: rdirectory/2 .. _code_metric/0::rdirectory/2: ``rdirectory/2`` ^^^^^^^^^^^^^^^^ Recursive version of the ``directory/1`` predicate using the given options. | **Compilation flags:** | ``static`` | **Template:** | ``rdirectory(Directory,Options)`` | **Mode and number of proofs:** | ``rdirectory(+atom,+list(compound))`` - ``one`` ------------ .. index:: rdirectory/1 .. _code_metric/0::rdirectory/1: ``rdirectory/1`` ^^^^^^^^^^^^^^^^ Recursive version of the ``directory/1`` predicate using default options. | **Compilation flags:** | ``static`` | **Template:** | ``rdirectory(Directory)`` | **Mode and number of proofs:** | ``rdirectory(+atom)`` - ``one`` ------------ .. index:: library/2 .. _code_metric/0::library/2: ``library/2`` ^^^^^^^^^^^^^ Prints metrics scores for all loaded entities from a given library using the given options. | **Compilation flags:** | ``static`` | **Template:** | ``library(Library,Options)`` | **Mode and number of proofs:** | ``library(+atom,+list(compound))`` - ``one`` ------------ .. index:: library/1 .. _code_metric/0::library/1: ``library/1`` ^^^^^^^^^^^^^ Prints metrics scores for all loaded entities from a given library using default options. | **Compilation flags:** | ``static`` | **Template:** | ``library(Library)`` | **Mode and number of proofs:** | ``library(+atom)`` - ``one`` ------------ .. index:: rlibrary/2 .. _code_metric/0::rlibrary/2: ``rlibrary/2`` ^^^^^^^^^^^^^^ Recursive version of the ``library/1`` predicate using the given options. | **Compilation flags:** | ``static`` | **Template:** | ``rlibrary(Library,Options)`` | **Mode and number of proofs:** | ``rlibrary(+atom,+list(compound))`` - ``one`` ------------ .. index:: rlibrary/1 .. _code_metric/0::rlibrary/1: ``rlibrary/1`` ^^^^^^^^^^^^^^ Recursive version of the ``library/1`` predicate using default options. | **Compilation flags:** | ``static`` | **Template:** | ``rlibrary(Library)`` | **Mode and number of proofs:** | ``rlibrary(+atom)`` - ``one`` ------------ .. index:: all/1 .. _code_metric/0::all/1: ``all/1`` ^^^^^^^^^ Scans all loaded entities and prints their metric scores using the given options. | **Compilation flags:** | ``static`` | **Template:** | ``all(Options)`` | **Mode and number of proofs:** | ``all(+list(compound))`` - ``one`` ------------ .. index:: all/0 .. _code_metric/0::all/0: ``all/0`` ^^^^^^^^^ Scans all loaded entities and prints their metric scores using default options. | **Compilation flags:** | ``static`` | **Mode and number of proofs:** | ``all`` - ``one`` ------------ .. index:: entity_score/2 .. _code_metric/0::entity_score/2: ``entity_score/2`` ^^^^^^^^^^^^^^^^^^ Score is a term that represents the metric score associated with a loaded entity. Fails if the metric does not apply. | **Compilation flags:** | ``static`` | **Template:** | ``entity_score(Entity,Score)`` | **Mode and number of proofs:** | ``entity_score(@entity_identifier,-ground)`` - ``zero_or_one`` ------------ .. index:: library_score/2 .. _code_metric/0::library_score/2: ``library_score/2`` ^^^^^^^^^^^^^^^^^^^ Score is a term that represents the metric score associated with a loaded library source files. Fails if the metric does not apply. | **Compilation flags:** | ``static`` | **Template:** | ``library_score(Library,Score)`` | **Mode and number of proofs:** | ``library_score(@atom,-ground)`` - ``zero_or_one`` ------------ .. index:: rlibrary_score/2 .. _code_metric/0::rlibrary_score/2: ``rlibrary_score/2`` ^^^^^^^^^^^^^^^^^^^^ Score is a term that represents the metric score associated with loaded source files from a library and its sub-libraries. Fails if the metric does not apply. | **Compilation flags:** | ``static`` | **Template:** | ``rlibrary_score(Library,Score)`` | **Mode and number of proofs:** | ``rlibrary_score(@atom,-ground)`` - ``zero_or_one`` ------------ .. index:: file_score/2 .. _code_metric/0::file_score/2: ``file_score/2`` ^^^^^^^^^^^^^^^^ Score is a term that represents the metric score associated with a loaded source file. Fails if the metric does not apply. | **Compilation flags:** | ``static`` | **Template:** | ``file_score(File,Score)`` | **Mode and number of proofs:** | ``file_score(@atom,-ground)`` - ``zero_or_one`` ------------ .. index:: directory_score/2 .. _code_metric/0::directory_score/2: ``directory_score/2`` ^^^^^^^^^^^^^^^^^^^^^ Score is a term that represents the metric score associated with loaded source files from a directory. Fails if the metric does not apply. | **Compilation flags:** | ``static`` | **Template:** | ``directory_score(Directory,Score)`` | **Mode and number of proofs:** | ``directory_score(@atom,-ground)`` - ``zero_or_one`` ------------ .. index:: rdirectory_score/2 .. _code_metric/0::rdirectory_score/2: ``rdirectory_score/2`` ^^^^^^^^^^^^^^^^^^^^^^ Score is a term that represents the metric score associated with loaded source files from a directory and its sub-directories. Fails if the metric does not apply. | **Compilation flags:** | ``static`` | **Template:** | ``rdirectory_score(Directory,Score)`` | **Mode and number of proofs:** | ``rdirectory_score(@atom,-ground)`` - ``zero_or_one`` ------------ .. index:: all_score/1 .. _code_metric/0::all_score/1: ``all_score/1`` ^^^^^^^^^^^^^^^ Score is a term that represents the metric score associated with all loaded source files. Fails if the metric does not apply. | **Compilation flags:** | ``static`` | **Template:** | ``all_score(Score)`` | **Mode and number of proofs:** | ``all_score(-ground)`` - ``zero_or_one`` ------------ .. index:: format_entity_score//2 .. _code_metric/0::format_entity_score//2: ``format_entity_score//2`` ^^^^^^^^^^^^^^^^^^^^^^^^^^ Formats the entity score for pretty printing. | **Compilation flags:** | ``static`` | **Template:** | ``format_entity_score(Entity,Score)`` | **Mode and number of proofs:** | ``format_entity_score(@entity_identifier,+ground)`` - ``one`` ------------ Protected predicates -------------------- .. index:: process_entity/2 .. _code_metric/0::process_entity/2: ``process_entity/2`` ^^^^^^^^^^^^^^^^^^^^ Processes an entity of the given kind. | **Compilation flags:** | ``static`` | **Template:** | ``process_entity(Kind,Entity)`` | **Mode and number of proofs:** | ``process_entity(+atom,@entity_identifier)`` - ``one`` ------------ .. index:: process_file/2 .. _code_metric/0::process_file/2: ``process_file/2`` ^^^^^^^^^^^^^^^^^^ Processes a source file using the given options. | **Compilation flags:** | ``static`` | **Template:** | ``process_file(Path,Options)`` | **Mode and number of proofs:** | ``process_file(+atom,+list(compound))`` - ``one`` ------------ .. index:: process_directory/2 .. _code_metric/0::process_directory/2: ``process_directory/2`` ^^^^^^^^^^^^^^^^^^^^^^^ Processes a directory of source files using the given options. | **Compilation flags:** | ``static`` | **Template:** | ``process_directory(Path,Options)`` | **Mode and number of proofs:** | ``process_directory(+atom,+list(compound))`` - ``one`` ------------ .. index:: process_rdirectory/2 .. _code_metric/0::process_rdirectory/2: ``process_rdirectory/2`` ^^^^^^^^^^^^^^^^^^^^^^^^ Recursively process a directory of source files using the given options. | **Compilation flags:** | ``static`` | **Template:** | ``process_rdirectory(Path,Options)`` | **Mode and number of proofs:** | ``process_rdirectory(+atom,+list(compound))`` - ``one`` ------------ .. index:: process_library/2 .. _code_metric/0::process_library/2: ``process_library/2`` ^^^^^^^^^^^^^^^^^^^^^ Processes a library of source files using the given options. | **Compilation flags:** | ``static`` | **Template:** | ``process_library(Library,Options)`` | **Mode and number of proofs:** | ``process_library(+atom,+list(compound))`` - ``one`` ------------ .. index:: process_rlibrary/2 .. _code_metric/0::process_rlibrary/2: ``process_rlibrary/2`` ^^^^^^^^^^^^^^^^^^^^^^ Recursively process a library of source files using the given options. | **Compilation flags:** | ``static`` | **Template:** | ``process_rlibrary(Library,Options)`` | **Mode and number of proofs:** | ``process_rlibrary(+atom,+list(compound))`` - ``one`` ------------ .. index:: process_all/1 .. _code_metric/0::process_all/1: ``process_all/1`` ^^^^^^^^^^^^^^^^^ Processes all loaded source code using the given options. | **Compilation flags:** | ``static`` | **Template:** | ``process_all(Options)`` | **Mode and number of proofs:** | ``process_all(+list(compound))`` - ``one`` ------------ .. index:: sub_directory/2 .. _code_metric/0::sub_directory/2: ``sub_directory/2`` ^^^^^^^^^^^^^^^^^^^ Enumerates, by backtracking, all directory sub-directories containing loaded files. | **Compilation flags:** | ``static`` | **Template:** | ``sub_directory(Directory,SubDirectory)`` | **Mode and number of proofs:** | ``sub_directory(+atom,-atom)`` - ``one`` ------------ .. index:: sub_library/2 .. _code_metric/0::sub_library/2: ``sub_library/2`` ^^^^^^^^^^^^^^^^^ Enumerates, by backtracking, all library sub-libraries. | **Compilation flags:** | ``static`` | **Template:** | ``sub_library(Library,SubLibrary)`` | **Mode and number of proofs:** | ``sub_library(+atom,-atom)`` - ``one`` ------------ Private predicates ------------------ (no local declarations; see entity ancestors if any) Operators --------- (none)