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.

Check#

class understand.Check#

Bases: object

A CodeCheck check

Use Check.list or Check.lookup to find checks.

A check compares equal to its id, so check == "CHECK_ID" works.

Methods Summary

description

Return the check description.

id

Return the id of the check.

list

Return a list of checks.

lookup

Return the check with the given id.

name

Return the name of the check.

options

Return the options available for the check.

tags

Return the tags of the check.

Methods Documentation

description() → str#

Return the check description.

Return type:

str

Returns:

the description, which may be an empty string

id() → str#

Return the id of the check.

Return type:

str

Returns:

the check id

classmethod list(target=None) → list[understand.Check]#

Return a list of checks.

Parameters:

target (understand.Db or None) – optional, list only checks that apply to the database. Some checks, like dependency checks, require a database to be found.

Return type:

list[understand.Check]

Returns:

the list of checks

classmethod lookup(id, db=None) → understand.Check#

Return the check with the given id.

Parameters:
  • id (str) – the check id

  • db (understand.Db or None) – optional, a database. Required to find checks that a project defines, such as dependency checks.

Return type:

understand.Check or None

Returns:

the check, or None if no check is found. Ids that only appear in results, such as “UND_ERROR” or rules from another tool’s SARIF file, return None.

name() → str#

Return the name of the check.

Return type:

str

Returns:

the check name

options() → understand.Options#

Return the options available for the check.

Return type:

understand.Options

Returns:

the check options

tags() → list[str]#

Return the tags of the check.

Checks that are not supported or always pass have the tags “Not Supported” and “Always Passes”.

Return type:

list[str]

Returns:

the list of tags