Jump to >

reviewbot.tools.base.mixins

Useful mixins for code checking tools.

New in version 3.0.

Classes

FilePatternsFromSettingMixin(**kwargs)

Mixin to set file patterns based on a configured tool setting.

FullRepositoryToolMixin()

Mixin for tools that need access to the entire repository.

JavaToolMixin()

Mixin for Java-based tools.

class FilePatternsFromSettingMixin(**kwargs)[source]

Bases: object

Mixin to set file patterns based on a configured tool setting.

Subclasses can base file patterns off either a setting representing a comma-separated list of file patterns, or a setting representing a comma-separated list of file extensions. If both are provided, both will be checked, with the file patterns taking precedence over file extensions.

If neither are provided by the user, the default list of file patterns set by the subclass (if any) will be used.

New in version 3.0.

file_extensions_setting = None[source]

The name of a tool setting for a comma-separated list of extensions.

Type:

unicode

file_patterns_setting = None[source]

The name of a tool setting for a comma-separated list of patterns.

Type:

unicode

include_default_file_patterns = True[source]

Whether to include default file patterns in the resulting list.

Type:

boolean

__init__(**kwargs)[source]

Initialize the tool.

Parameters

**kwargs (dict) – Keyword arguments for the tool.

__annotations__ = {}[source]
class FullRepositoryToolMixin[source]

Bases: object

Mixin for tools that need access to the entire repository.

This will take care of checking out a copy of the repository and applying patches from the diff being reviewed.

New in version 3.0: This replaced the legacy reviewbot.tools.RepositoryTool.

working_directory_required = True[source]
execute(review, repository=None, base_commit_id=None, **kwargs)[source]

Perform a review using the tool.

Parameters
  • review (reviewbot.processing.review.Review) – The review object.

  • settings (dict, optional) – Tool-specific settings.

  • repository (reviewbot.repositories.Repository, optional) – The repository.

  • base_commit_id (unicode, optional) – The ID of the commit that the patch should be applied to.

__annotations__ = {}[source]
class JavaToolMixin[source]

Bases: object

Mixin for Java-based tools.

New in version 3.0.

java_main = None[source]

Main class to call to run the Java application.

Type:

unicode

java_classpaths_key = None[source]

The key identifying the classpaths to use.

Type:

unicode

exe_dependencies = ['java'][source]
classmethod set_has_java_runtime(has_runtime)[source]

Set whether there’s a Java runtime installed.

Parameters

has_runtime (bool) – Whether there’s a runtime installed.

classmethod clear_has_java_runtime()[source]

Clear whether there’s a Java runtime installed.

This will force the next dependency check to re-check for a runtime.

check_dependencies()[source]

Verify the tool’s dependencies are installed.

This will invoke the base class’s dependency checking, ensuring that java is available, and will then attempt to run the configured Java class (java_main), checking that it could be found.

Returns

True if all dependencies for the tool are satisfied. If this returns False, the worker will not listen for this Tool’s queue, and a warning will be logged.

Return type

bool

build_base_command(**kwargs)[source]

Build the base command line used to review files.

Parameters

**kwargs (dict, unused) – Additional keyword arguments.

Returns

The base command line.

Return type

list of unicode

__annotations__ = {}[source]