Check

class understand.Check

Bases: object

CodeCheck plugin check object

The Check object is passed to the define_options(check) and check(check) functions of CodeCheck plugins. It’s used to retrieve arguments such as the database and to report violations. Plugins can define and retrieve custom Options with the options method.

Methods Summary

cache

Return a cache that can be used to store, retrieve, and share data.

db

Return the database associated with this check.

files

Return the list of files associated with this check.

id

Return the id of this check.

is_aborted

Return True if the check has been aborted by the user.

option

Equivalent to options

options

Return the Options object associated with this check.

violation

Emit a violation of this check.

Methods Documentation

cache([id]) understand.Cache

Return a cache that 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:

understand.Cache

Returns:

a cache object or None

db() understand.Db

Return the database associated with this check.

Return type:

understand.Db

Returns:

the database

files() list[understand.Ent]

Return the list of files associated with this check.

Return type:

list[understand.Ent]

Returns:

the list of files

id() str

Return the id of this check.

Return type:

str

Returns:

the check id

is_aborted() bool

Return True if the check has been aborted by the user.

Return type:

bool

Returns:

True if the check has been aborted by the user

option() understand.Options

Equivalent to options

options() understand.Options

Return the Options object associated with this check.

Return type:

understand.Options

Returns:

the Options object associated with this check

violation(entity, file, line, column, text) understand.CheckViolation

Emit a violation of this check.

Parameters:
  • entity (understand.Ent or None) – an entity causing the violation

  • file (understand.Ent or None) – the file entity the violation occurs in

  • line (int) – the line number of the violation

  • column (int) – the column number of the violation

  • text (str) – the text describing the violation. This can contain placeholders (%1, %2, etc) and any additional arguments will be used to populate the placeholders.

Return type:

understand.CheckViolation

Returns:

the violation object that was created

Violation line and column numbers are 1-based.