Check¶
- class understand.Check¶
Bases:
objectCodeCheck 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
databaseand to reportviolations. Plugins can define and retrieve customOptionswith theoptionsmethod.Methods Summary
Return a
cachethat can be used to store, retrieve, and share data.Return the database associated with this check.
Return the list of files associated with this check.
Return the id of this check.
Return True if the check has been aborted by the user.
Equivalent to
optionsReturn the Options object associated with this check.
Emit a violation of this check.
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 check.
- Return type:
- 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:
- 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:
- Returns:
the violation object that was created
Violation line and column numbers are 1-based.