class compunit_metricclass_manager

Manages the compunit granularity metric classes ( compunit_metricclass ) associated with an analysis.

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

for e in compunit_metricclass_manager.metricclasses():
    print('compunit_metricclass: ', e)

compunit_metricclass_manager Details

class cs.compunit_metricclass_manager

Manages the compunit granularity metric classes ( compunit_metricclass ) associated with an analysis.

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

Create and return a new compunit_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:

compunit_metricclass

Returns:

The newly-created compunit_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 compunit_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.

>>> compunit_metricclass_manager.create('else', '<cs.depfilter_point_directive show>', metricclass_flags.POST_ANALYSIS)
<cs.metricclass else>
>>> compunit_metricclass_manager.create('foo', 'foo')
<cs.metricclass foo>
static lookup(tag)

Get the compunit_metricclass that has the specified tag.

Parameters:tag (str) – The metric class tag.
Return type:compunit_metricclass
Returns:The compunit_metricclass with the specified tag.
Raises:result.ELEMENT_NOT_PRESENT
>>> compunit_metricclass_manager.lookup('data-control')
<cs.metricclass data-control>
static metricclasses()

Get an iterator over the metric classes ( compunit_metricclass ) in a compunit_metricclass_manager .

Return type:compunit_metricclass_iterator
Returns:The initialized iterator.
>>> compunit_metricclass_manager.metricclasses()
<cs.compunitmetricclass_iterator begin>