code_metric — Logtalk 3.100.1

category

# `code_metric`

Core predicates for computing source code metrics.

Availability:
`logtalk_load(code_metrics(loader))`
Author: Ebrahim Azarisooreh and Paulo Moura
Version: 0:13:0
Date: 2025-10-06
Compilation flags:
`static`
Extends:
`public` code_metrics_utilities
`public` options
Uses:
list
logtalk
os
type
Remarks:
(none)
Inherited public predicates:
check_option/1 check_options/1 default_option/1 default_options/1 option/2 option/3 valid_option/1 valid_options/1

## Public predicates

### `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`

### `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`

### `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`

### `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`

### `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`

### `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`

### `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`

### `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`

### `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`

### `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`

### `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`

### `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`

### `all/0`

Scans all loaded entities and prints their metric scores using default options.

Compilation flags:
`static`
Mode and number of proofs:
`all` - `one`

### `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`

### `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`

### `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`

### `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`

### `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`

### `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`

### `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`

### `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

### `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`

### `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`

### `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`

### `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`

### `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`

### `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`

### `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`

### `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`

### `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)