CheckViolation

class understand.CheckViolation

Bases: object

CodeCheck plugin violation object

Violations are returned from Check.violation. Use the violation object to add fix-it hints.

Violation line and column numbers are 1-based.

Methods Summary

add_fixit_hint

Add a fix-it hint associated with this violation.

add_highlight

Add a highlight associated with this violation.

add_note

Add a note associated with this violation.

Methods Documentation

add_fixit_hint(line, column, end_line, end_column[, text]) None

Add a fix-it hint associated with this violation.

Parameters:
  • line (int) – the first line in the range of text

  • column (int) – the first column in the range of text

  • end_line (int) – the last line in the range of text

  • end_column (int) – the last column in the range of text

  • text (str or None) – optional, the replacement text.

Return type:

None

The line, column, end_line, and end_column describe a range of text to be replaced in the file. The range can be empty to indicate pure insertion. The text is the replacement text. It can be empty for pure removal.

add_highlight(line, column, end_line, end_column) None

Add a highlight associated with this violation.

Parameters:
  • line (int) – the first line in the range of text

  • column (int) – the first column in the range of text

  • end_line (int) – the last line in the range of text

  • end_column (int) – the last column in the range of text

Return type:

None

add_note(file, line, column, text) understand.ViolationNote

Add a note associated with this violation.

Parameters:
  • file (understand.Ent or None) – the file entity the note occurs in

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

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

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

Return type:

understand.ViolationNote

Returns:

the note object that was created