category

# `code_metric`

Core predicates for computing source code metrics.

Author: Ebrahim Azarisooreh and Paulo Moura
Version: 0:9:0
Date: 2019-09-23
Compilation flags:
`static`
Uses:
list
logtalk
os
Remarks:
(none)
Inherited public predicates:
(none)

- Public predicates

  - `entity/1`

  - `file/1`

  - `directory/1`

  - `rdirectory/1`

  - `library/1`

  - `rlibrary/1`

  - `all/0`

  - `entity_score/2`

  - `library_score/2`

  - `rlibrary_score/2`

  - `file_score/2`

  - `directory_score/2`

  - `rdirectory_score/2`

  - `all_score/1`

  - `entity_score//2`

- Protected predicates

  - `process_entity/2`

  - `process_file/1`

  - `process_directory/1`

  - `process_rdirectory/1`

  - `process_library/1`

  - `process_rlibrary/1`

  - `process_all/0`

  - `sub_directory/2`

  - `sub_library/2`

- Private predicates

- Operators

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

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

### `rdirectory/1`

Recursive version of the `directory/1` predicate.

Compilation flags:
`static`
Template:
`rdirectory(Directory)`
Mode and number of proofs:
`rdirectory(+atom)` - `one`

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

### `rlibrary/1`

Recursive version of the `library/1` predicate.

Compilation flags:
`static`
Template:
`rlibrary(Library)`
Mode and number of proofs:
`rlibrary(+atom)` - `one`

### `all/0`

Scans all loaded entities and prints their metric scores.

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

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

### `entity_score//2`

Pretty prints the entity score.

Compilation flags:
`static`
Template:
`entity_score(Entity,Score)`
Mode and number of proofs:
`entity_score(@entity_identifier,-ground)` - `zero_or_one`
`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/1`

Processes a source file.

Compilation flags:
`static`
Template:
`process_file(Path)`
Mode and number of proofs:
`process_file(+atom)` - `one`

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

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

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

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

### `process_all/0`

Processes all loaded source code.

Compilation flags:
`static`
Mode and number of proofs:
`process_all` - `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)