class sfile_metricclass_manager¶
Manages the sfile granularity metric classes ( sfile_metricclass ) associated with an analysis.
Use a sfile_metricclass_iterator to iterate over the sfile-granularity metric classes associated with an analysis. For example:
for e in sfile_metricclass_manager.metricclasses():
print('sfile_metricclass: ', e)
sfile_metricclass_manager Members¶
| Constructors | none |
| Static Methods | create(), lookup(), metricclasses() |
sfile_metricclass_manager Details¶
-
class
cs.sfile_metricclass_manager¶ Manages the
sfilegranularity metric classes (sfile_metricclass) associated with an analysis.-
static
create(tag, desc[, flags = metricclass_flags.NONE])¶ Create and return a new
sfile_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_flagscharacterizing the new metric class.
Return type: Returns: The newly-created
sfile_metricclass.Raises: result.ELEMENT_ALREADY_PRESENTif there is already asfile_metricclasswhose tag istag.result.ERROR_INVALID_ARGUMENTiftagordescdoes not conform to the requirements described above.result.ERROR_INVALID_PHASE_FOR_OPERATIONif called outside the top level scope of the plug-in.
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
sfile_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.
>>> sfile_metricclass_manager.create('alex', 'endbox', metricclass_flags.AUTO) <cs.metricclass alex>
>>> sfile_metricclass_manager.create('reserved', '-D__SSP__=1') <cs.metricclass reserved>
- tag (str) –
-
static
lookup(tag)¶ Get the
sfile_metricclassthat has the specifiedtag.Parameters: tag (str) – The metric class tag. Return type: sfile_metricclassReturns: The sfile_metricclasswith the specifiedtag.Raises: result.ELEMENT_NOT_PRESENT>>> sfile_metricclass_manager.lookup('LCodeOnly') <cs.metricclass LCodeOnly>
-
static
metricclasses()¶ Get an iterator over the metric classes (
sfile_metricclass) in asfile_metricclass_manager.Return type: sfile_metricclass_iteratorReturns: The initialized iterator. >>> for mc in sfile_metricclass_manager.metricclasses(): # iteration managed by sfile_metricclass_iterator.__iter__() ... # and sfile_metricclass_iterator.__next__() ... if 'taint' in mc.tag().lower(): ... print(mc.tag()) ... TaintSource TaintSink TaintProp
-
static