The Understand Python API gives scripts access to everything Understand knows about your code — entities, references, metrics, and dependencies — and powers custom checks, graphs, and reports.
MetricContext#
- class understand.MetricContext#
Bases:
objectMetric plugin object
This object is provided to a metric plugin’s test_* and value functions. Use the
id()to find the requested metric id. Useoptions()to define and lookup custom options.Methods Summary
Return a
cachethat can be used to store, retrieve, and share data.Return the database associated with this metric.
The id of the requested metric.
Return True if metric generation has been aborted by the user.
Return the list of built-in metrics
Return the Options object associated with this metric.
Methods Documentation
- cache(id='') understand.Cache#
Return a
cachethat can be used to store, retrieve, and share data. If id is not given, it will be a script-specific identifier. This function may return None if caching is not available.- Return type:
- Returns:
a cache object or None
- db() understand.Db#
Return the database associated with this metric.
- Return type:
- Returns:
the database
- id() str#
The id of the requested metric.
- Return type:
str
- is_aborted() bool#
Return True if metric generation has been aborted by the user.
- Return type:
bool
- Returns:
True if metric generation has been aborted by the user
- list(ent) list[str]#
- list(arch) list[str]
- list(db) list[str]
- list(entkindstr) list[str]
Return the list of built-in metrics
This only lists metrics calculated by Understand, and does not include any metrics provided by plugins. So, it is safe to call from a metric plugin. This function should be used instead of the following four functions:
ent.metrics,arch.metrics,db.metrics, orMetrics.list. Those functions are not safe to call from a Metric plugin because they include metrics defined by metric plugins.- Parameters:
arch (understand.Arch) – an architecture to list metrics for
ent (understand.Ent) – an entity to list metrics for
db (understand.Db) – a database to list metrics for
entkindstr (str) – an entity kind string which may be empty.
- Return type:
list[str]
- options() understand.Options#
Return the Options object associated with this metric.
- Return type:
- Returns:
the options object