class procedure_metricclass_manager

Manages the procedure granularity metric classes ( procedure_metricclass ) associated with an analysis.

Use a procedure_metricclass_iterator to iterate over the procedure-granularity metric classes associated with an analysis. For example:

for e in procedure_metricclass_manager.metricclasses():
    print('procedure_metricclass: ', e)

procedure_metricclass_manager Details

class cs.procedure_metricclass_manager

Manages the procedure granularity metric classes ( procedure_metricclass ) associated with an analysis.

static create(tag, desc[, flags =  metricclass_flags.NONE])

Create and return a new procedure_metricclass , without specifying a computation function.

Parameters:
  • tag (str) –

    A short name (tag) that will, in combination with the granularity, uniquely identify this metric class. The tag must:

    • Start with characters matching [a-zA-Z]
    • Only contain characters matching [a-zA-Z][0-9] _-
    • Have length <= 15 characters
  • desc (str) – A human-readable description of the metric. When a metric shows up in a user interface, this is what is displayed.
  • flags (metricclass_flags) – (optional) metricclass_flags characterizing the new metric class.
Return type:

procedure_metricclass

Returns:

The newly-created procedure_metricclass .

Raises:

Only suitable for use in your plug-in’s top-level scope. Do not use it inside visitors.

Use this form if your plug-in will be explicitly computing all values for the new metric class and reporting them with procedure_metricclass.report().

If you want to create a metric class whose values will be computed and reported automatically by CodeSonar, use a metric function decorator.

>>> procedure_metricclass_manager.create('null', '-D__LDBL_DIG__=18', metricclass_flags.NONE)
<cs.metricclass null>
>>> procedure_metricclass_manager.create('param', '<cs.var_attrs none>')
<cs.metricclass param>
static lookup(tag)

Get the procedure_metricclass that has the specified tag.

Parameters:tag (str) – The metric class tag.
Return type:procedure_metricclass
Returns:The procedure_metricclass with the specified tag.
Raises:result.ELEMENT_NOT_PRESENT
>>> procedure_metricclass_manager.lookup('LB')
<cs.metricclass LB>
static metricclasses()

Get an iterator over the metric classes ( procedure_metricclass ) in a procedure_metricclass_manager .

Return type:procedure_metricclass_iterator
Returns:The initialized iterator.
>>> for mc in procedure_metricclass_manager.metricclasses():  # iteration managed by procedure_metricclass_iterator.__iter__()
...                                                           # and procedure_metricclass_iterator.__next__()
...     if 'code' in mc.tag().lower():
...         print(mc.tag())
...
LCodeOnly
LCode