• Get Review Board
  • What's New
  • Products
  • Review Board Code review, image review, and document review
  • Documentation
  • Release Notes
  • Power Pack Enterprise integrations, reports, and enhanced document review
  • Try for 60 Days
  • Purchase
  • RBCommons Review Board as a Service, hosted by us
  • Pricing
  • RBTools Command line tools and Python API for Review Board
  • Documentation
  • Release Notes
  • Review Bot Automated code review, connecting tools you already use
  • Documentation
  • Release Notes
  • RB Gateway Manage Git and Mercurial repositories in your network
  • Documentation
  • Release Notes
  • Learn and Explore
  • What is Code Review?
  • Documentation
  • Frequently Asked Questions
  • Support Options
  • Third-Party Integrations
  • Demo
  • Review Board RBTools Power Pack Review Bot Djblets RB Gateway
    1. Review Bot 4.x
    2. Version 4.x
    3. Version 3.0
    4. Version 2.0
    5. Version 1.0
    6. Module and Class Reference
    7. reviewbot.tools.cargotool
  • Home
  • Installation
  • Manually Installing Review Bot
  • Review Bot Docker Images
  • Upgrading Review Bot
  • Configuring Review Bot
  • Review Bot Tools
  • Cargo Tool
  • Checkstyle
  • Clang Static Analyzer
  • Cppcheck
  • Cpplint
  • Doc8
  • FBInfer
  • Flake8
  • Go Fmt
  • Go Tool
  • JSHint
  • PMD
  • Pycodestyle
  • Pydocstyle
  • Pyflakes
  • RuboCop
  • Rust Fmt
  • Secret Scanner
  • ShellCheck
  • Module and Class Reference
  • reviewbot.tools.base
  • reviewbot.tools.base.mixins
  • reviewbot.tools.base.registry
  • reviewbot.tools.base.tool
  • reviewbot.testing.testcases
  • reviewbot.testing.utils
  • reviewbot.tools.testing
  • reviewbot.tools.testing.decorators
  • reviewbot.tools.testing.testcases
  • reviewbot.processing.review
  • reviewbot.utils.api
  • reviewbot.utils.filesystem
  • reviewbot.utils.log
  • reviewbot.utils.process
  • reviewbot.utils.text
  • reviewbot.celery
  • reviewbot.config
  • reviewbot.deprecation
  • reviewbot.errors
  • reviewbot.repositories
  • reviewbot.tasks
  • reviewbot.tools.cargotool
  • reviewbot.tools.checkstyle
  • reviewbot.tools.clang
  • reviewbot.tools.cppcheck
  • reviewbot.tools.cpplint
  • reviewbot.tools.doc8
  • reviewbot.tools.fbinfer
  • reviewbot.tools.flake8
  • reviewbot.tools.gofmt
  • reviewbot.tools.gotool
  • reviewbot.tools.jshint
  • reviewbot.tools.pmd
  • reviewbot.tools.pycodestyle
  • reviewbot.tools.pydocstyle
  • reviewbot.tools.pyflakes
  • reviewbot.tools.rbsecretscanner
  • reviewbot.tools.rubocop
  • reviewbot.tools.rustfmt
  • reviewbot.tools.shellcheck
  • General Index
  • Python Module Index
  • Release Notes
  • reviewbot.tools.cargotool¶

    Review Bot tool to run Cargo commands.

    Classes

    CargoTool([settings])

    Review Bot tool to run Cargo Commands.

    class CargoTool(settings=None, **kwargs)[source]¶

    Bases: FullRepositoryToolMixin, BaseTool

    Review Bot tool to run Cargo Commands.

    name = 'CargoTool'[source]¶

    The displayed name of the tool.

    Type:

    str

    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 Rust code for linting and test errors using built-in Rust tools "cargo clippy", and "cargo test".'[source]¶

    A short description of the tool.

    Type:

    str

    timeout = 120[source]¶

    Timeout for tool execution, in seconds.

    Type:

    int

    exe_dependencies = ['cargo', 'cargo-clippy'][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 the exe_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 = ['*.rs'][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). See fnmatch 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 of str

    options = [{'name': 'clippy', 'field_type': 'django.forms.BooleanField', 'default': True, 'field_options': {'label': 'Check and lint code', 'required': False, 'help_text': 'Compile using "cargo clippy", checking for errors.'}}, {'name': 'test', 'field_type': 'django.forms.BooleanField', 'default': False, 'field_options': {'label': 'Run tests', 'required': False, 'help_text': 'Run unit tests using "cargo test".'}}][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() and handle_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

    TEST_GROUP_RE = re.compile('running (?P<num_tests>[1-9]\\d*) tests?\\n.*?\\nfailures:\\n(?P<test_output>.+?)\\ntest result: FAILED\\. \\d+ passed; (?P<num_failed>\\d+) failed;', re.DOTALL)[source]¶
    TEST_LINES_LIMIT = 100[source]¶
    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 str

    handle_files(files, review, base_command, **kwargs)[source]¶

    Perform a review of all files.

    Parameters:
    • files (list of reviewbot.processing.review.File) – The files to process.

    • review (reviewbot.processing.review.Review) – The review being populated.

    • base_command (list of str) – The base command used to run cargo.

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

    handle_file(f, path, file_results, **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.

    • file_results (dict) – Lists of cargo clippy results, keyed by local temp file path.

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

    run_cargo_clippy(base_command)[source]¶

    Run cargo clippy on a codebase.

    This will check for lintian/syntax errors. It won’t directly report them, but will return payloads information covering all files with compiler-message results that will then be handled in handle_file().

    Parameters:

    base_command (list of str) – The base command used to run cargo.

    Returns:

    A 2-tuple containing:

    1. A dictionary mapping absolute file paths to lists of clippy result payload dictionaries.

    2. A boolean indicating whether a compiler error was found.

    Return type:

    tuple

    run_cargo_test(review, base_command)[source]¶

    Run cargo test on a codebase.

    THis will run the test suite and parse the results. If unit tests failed, a general comment will be left showing up to TEST_LINES_LIMIT lines of unit test output.

    Parameters:

    base_command (list of str) – The base command used to run cargo.

    __annotations__ = {}¶

    Keep up with the latest Review Board releases, security updates, and helpful information.

    About
    News
    Demo
    RBCommons Hosting
    Integrations
    Happy Users
    Support Options
    Documentation
    FAQ
    User Manual
    RBTools
    Administration Guide
    Power Pack
    Release Notes
    Downloads
    Review Board
    RBTools
    Djblets
    Power Pack
    Package Store
    PGP Signatures
    Contributing
    Bug Tracker
    Submit Patches
    Development Setup
    Wiki
    Follow Us
    Mailing Lists
    Reddit
    Twitter
    Mastodon
    Facebook
    YouTube

    Copyright © 2006-2025 Beanbag, Inc. All rights reserved.

    Terms of Service — Privacy Policy — AI Ethics Policy — Branding

    On this page

    • [Top]
    • CargoTool
      • CargoTool.name
      • CargoTool.version
      • CargoTool.description
      • CargoTool.timeout
      • CargoTool.exe_dependencies
      • CargoTool.file_patterns
      • CargoTool.options
      • CargoTool.TEST_GROUP_RE
      • CargoTool.TEST_LINES_LIMIT
      • CargoTool.build_base_command()
      • CargoTool.handle_files()
      • CargoTool.handle_file()
      • CargoTool.run_cargo_clippy()
      • CargoTool.run_cargo_test()
      • CargoTool.__annotations__