Jump to >

ShellCheck

New in version 3.0.

ShellCheck is a static analysis tool for bash/sh/ksh/dash shell scripts that provides warnings for easy-to-miss issues and suggestions for best practices.

Supported File Types

The following are supported by this tool:

  • Shell Scripts: *.bash, *.bats, *.dash, *.ksh, *.sh

It will also check any files starting with a shebang (#!) line pointing to bash, dash, ksh, or sh.

Installation

shellcheck can be installed through your package manager. See ShellCheck’s installation instructions for more information.

Configuration

ShellCheck Location

If the shellcheck command is in a non-standard location, and can’t be found in Review Bot’s PATH environment variable, then you’ll need to specify the path in the Review Bot worker config file:

exe_paths = {
    'shellcheck': '/path/to/shellcheck',
}

You will need to restart the Review Bot worker after making this change.

Enabling ShellCheck in Review Board

First, you’ll need to add a Review Bot configuration in Review Board (see Tool Configurations).

The following configuration options are available:

Minimum severity (required):

The minimum severity level for commenting on issues. The following choices are available, in order of severity:

  • style – Reports on style issues, or anything more severe

  • info – Reports on informative suggestions, or anything more severe

  • warning – Reports on warnings in code, or anything more severe

  • error – Reports on errors in code

This is equivalent to shellcheck --severity=....

Exclude (optional):

A comma-separated list of error codes to exclude.

This is equivalent to shellcheck --exclude=....

See the list of shellcheck error codes for possible values.