.. 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:10:0 | **Date:** 2022-05-05 | **Compilation flags:** | ``static`` | **Uses:** | :ref:`list ` | :ref:`logtalk ` | :ref:`os ` | **Remarks:** | (none) | **Inherited public predicates:** | (none) .. 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/1 .. _code_metric/0::file/1: ``file/1`` ^^^^^^^^^^ Prints metric scores for all the entities defined in a loaded source file. | **Compilation flags:** | ``static`` | **Template:** | ``file(File)`` | **Mode and number of proofs:** | ``file(+atom)`` - ``zero_or_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. | **Compilation flags:** | ``static`` | **Template:** | ``directory(Directory)`` | **Mode and number of proofs:** | ``directory(+atom)`` - ``one`` ------------ .. index:: rdirectory/1 .. _code_metric/0::rdirectory/1: ``rdirectory/1`` ^^^^^^^^^^^^^^^^ Recursive version of the ``directory/1`` predicate. | **Compilation flags:** | ``static`` | **Template:** | ``rdirectory(Directory)`` | **Mode and number of proofs:** | ``rdirectory(+atom)`` - ``one`` ------------ .. index:: library/1 .. _code_metric/0::library/1: ``library/1`` ^^^^^^^^^^^^^ Prints metrics scores for all loaded entities from a given library. | **Compilation flags:** | ``static`` | **Template:** | ``library(Library)`` | **Mode and number of proofs:** | ``library(+atom)`` - ``one`` ------------ .. index:: rlibrary/1 .. _code_metric/0::rlibrary/1: ``rlibrary/1`` ^^^^^^^^^^^^^^ Recursive version of the ``library/1`` predicate. | **Compilation flags:** | ``static`` | **Template:** | ``rlibrary(Library)`` | **Mode and number of proofs:** | ``rlibrary(+atom)`` - ``one`` ------------ .. index:: all/0 .. _code_metric/0::all/0: ``all/0`` ^^^^^^^^^ Scans all loaded entities and prints their metric scores. | **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/1 .. _code_metric/0::process_file/1: ``process_file/1`` ^^^^^^^^^^^^^^^^^^ Processes a source file. | **Compilation flags:** | ``static`` | **Template:** | ``process_file(Path)`` | **Mode and number of proofs:** | ``process_file(+atom)`` - ``one`` ------------ .. index:: process_directory/1 .. _code_metric/0::process_directory/1: ``process_directory/1`` ^^^^^^^^^^^^^^^^^^^^^^^ Processes a directory of source files. | **Compilation flags:** | ``static`` | **Template:** | ``process_directory(Path)`` | **Mode and number of proofs:** | ``process_directory(+atom)`` - ``one`` ------------ .. index:: process_rdirectory/1 .. _code_metric/0::process_rdirectory/1: ``process_rdirectory/1`` ^^^^^^^^^^^^^^^^^^^^^^^^ Recursively process a directory of source files. | **Compilation flags:** | ``static`` | **Template:** | ``process_rdirectory(Path)`` | **Mode and number of proofs:** | ``process_rdirectory(+atom)`` - ``one`` ------------ .. index:: process_library/1 .. _code_metric/0::process_library/1: ``process_library/1`` ^^^^^^^^^^^^^^^^^^^^^ Processes a library of source files. | **Compilation flags:** | ``static`` | **Template:** | ``process_library(Library)`` | **Mode and number of proofs:** | ``process_library(+atom)`` - ``one`` ------------ .. index:: process_rlibrary/1 .. _code_metric/0::process_rlibrary/1: ``process_rlibrary/1`` ^^^^^^^^^^^^^^^^^^^^^^ Recursively process a library of source files. | **Compilation flags:** | ``static`` | **Template:** | ``process_rlibrary(Library)`` | **Mode and number of proofs:** | ``process_rlibrary(+atom)`` - ``one`` ------------ .. index:: process_all/0 .. _code_metric/0::process_all/0: ``process_all/0`` ^^^^^^^^^^^^^^^^^ Processes all loaded source code. | **Compilation flags:** | ``static`` | **Mode and number of proofs:** | ``process_all`` - ``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)