2.6. gnatmetric module

GNAThub plug-in for the GNATmetric and LALmetric command-line tool.

It exports the GNATmetric class which implements the GNAThub.Plugin interface. This allows GNAThub’s plug-in scanner to automatically find this module and load it as part of the GNAThub default execution.

class gnatmetric.GNATmetric[source]

Bases: Plugin, Runner, Reporter

GNATmetric & LALmetric plugin for GNAThub.

RANKING = 2
VALID_EXIT_CODES = (0, 1)
__init__()[source]

Initialize instance properties.

property name

Return the name of the tool.

Returns:

the tool name

Return type:

str

parse_config(tree)[source]

Parse the config block to retrieve the names to be displayed for each rule.

parse_metrics(node, entity=False)[source]

Parse the xml node returns a list of metrics

parse_units(node, resource)[source]

Recursively parse the unit node until all of them are found

report()[source]

Parse GNATmetric XML report and save data to the database.

Returns according to the success of the analysis:

  • GNAThub.EXEC_SUCCESS: transactions committed to database

  • GNAThub.EXEC_FAILURE: error while parsing the xml report

run()[source]

Execute GNATmetric.

Returns according to the success of the execution of the tool:

  • GNAThub.EXEC_SUCCESS: on successful execution

  • GNAThub.EXEC_FAILURE: on any error