reviewbot.tools.gotool¶
Review Bot tool to run Go Tools.
Classes
|
Review Bot tool to run Go Tools. |
- class GoTool(settings=None, **kwargs)[source]¶
Bases:
FullRepositoryToolMixin
,BaseTool
Review Bot tool to run Go Tools.
- version = '1.0'[source]¶
The compatibility version of the tool.
This should only be changed for major breaking updates. It will break compatibility with existing integration configurations, requiring manual updates to those configurations. Any existing configurations referencing the old version will not be run, unless an older version of the tool is being handled through another Review Bot worker providing the older tool.
- Type:
str
- description = 'Checks Go code for test errors using built-in Go tools "go test", and "go vet".'[source]¶
A short description of the tool.
- Type:
str
- exe_dependencies = ['go'][source]¶
A list of executable tools required by the tool.
Each is the name of an executable on the filesystem, either in the
PATH
or defined in theexe_paths
configuration.These will be checked when the worker starts. If a dependency for a tool is missing, the worker will not enable it.
New in version 3.0: Tools that previously implemented
check_dependencies()
may want to be updated to use this.- Type:
dict
- file_patterns = ['*.go'][source]¶
A list of filename patterns this tool can process.
This is intended for tools that have a fixed list of file extensions or specific filenames they should process. Each entry is a glob file pattern (e.g.,
*.py
,.config/*.xml
,dockerfile
, etc.), and must be lowercase (as filenames will be normalized to lowercase for comparison). Seefnmatch
for pattern rules.Tools can leave this empty to process all files, or can override
get_can_handle_file()
to implement custom logic (e.g., basing matching off a tool’s settings, or providing case-sensitive matches).New in version 3.0.
- Type:
list
ofstr
- options = [{'name': 'test', 'field_type': 'django.forms.BooleanField', 'default': False, 'field_options': {'label': 'Run tests', 'required': False, 'help_text': 'Run unit tests using "go test".'}}, {'name': 'vet', 'field_type': 'django.forms.BooleanField', 'default': True, 'field_options': {'label': 'Vet code', 'required': False, 'help_text': 'Run lint checks against code using "go vet".'}}][source]¶
Configurable options defined for the tool.
Each item in the list is a dictionary representing a form field to display in the Review Board administration UI. Keys include:
field_type
(str
):The full path as a string to a Django form field class to render.
name
(str
):The name/ID of the field. This will map to the key in the settings provided to
handle_files()
andhandle_file()
.default
(object
, optional):The default value for the field.
field_options
(dict
, optional):Additional options to pass to the form field’s constructor.
widget
(dict
, optional):Information on the Django form field widget class used to render the field. This dictionary includes the following keys:
type
(str
):The full path as a string to a Django form field widget class.
attrs
(dict
, optional):A dictionary of attributes passed to the widget’s constructor.
- Type:
list
- VET_ERROR_RE = re.compile('^(vet: )?(?P<path>.*\\.go):(?P<linenum>\\d+):(?P<column>\\d+): (?P<text>.*)$', re.MULTILINE)[source]¶
- get_can_handle_file(review_file, **kwargs)[source]¶
Return whether this tool can handle a given file.
- Parameters:
review_file (
reviewbot.processing.review.File
) – The file to check.**kwargs (
dict
, unused) – Additional keyword arguments passed toexecute()
. This is intended for future expansion.
- Returns:
True
if the file can be handled.False
if it cannot.- Return type:
bool
- handle_files(files, review, **kwargs)[source]¶
Perform a review of all files.
- Parameters:
files (
list
ofreviewbot.processing.review.File
) – The files to process.review (
reviewbot.processing.review.Review
) – The review that comments will apply to.**kwargs (
dict
) – Additional keyword arguments.
- handle_file(f, path, packages, patched_files_map, **kwargs)[source]¶
Perform a review of a single file.
- Parameters:
f (
reviewbot.processing.review.File
) – The file to process.path (
str
) – The local path to the patched file to review.packages (
set
ofstr
) – A set of all package names. This function will add the file’s package to this set.patched_files_map (
dict
) – A mapping of paths to files being reviewed. This function will add the path and file to this map.**kwargs (
dict
, unused) – Additional keyword arguments.
- run_go_test(package, review)[source]¶
Execute ‘go test’ on a given package
- Parameters:
package (
str
) – Name of the go package.review (
reviewbot.processing.review.Review
) – The review object.
- run_go_vet(package, patched_files_map)[source]¶
Execute ‘go vet’ on a given package
- Parameters:
package (
str
) – Name of the go package.patched_files_map (
dict
) – Mapping from filename toFile
to add comments.
- __annotations__ = {}¶