Inspections of BashSupport Pro
BashSupport Pro provides a set of inspections to help you write better Bash.
Additionally, ShellCheck is executed to highlight the most common problems of your scripts. Please refer to ShellCheck integration to learn more about it.
BashSupport Pro
Shebang in plain text files
Highlights plain text files, which have no extension, but a supported shebang line.
A quickfix allows to mark and open such a file as a shell script file.
Even if BashSupport Pro attempts to mark those files as shell scripts, the IDE sometimes associates files with the plain text file type.
- Dateien:
- Textdateien
Local use of variable
Highlights global variable declarations, which could be declared as local
.
Variable declarations are only highlighted, if there are no references to it outside the current function.
- Kommentar um die Warnung zu unterdrücken:
# bashsupport disable=BP2001
Unused local variable
This inspection marks local variables as unused, which are not referenced.
The message is displayed under these conditions:
- The variable is declared as
local
in a function - It’s the first declaration of that variable in that function
- It’s not exported and there are no references to that variable in the function
- Kommentar um die Warnung zu unterdrücken:
# bashsupport disable=BP3001
Unused global variable
Marks global variable definitions, which appear unused. If a variable is exported, then it’s not highlighted.
- Kommentar um die Warnung zu unterdrücken:
# shellcheck disable=SC2034
Unused function argument
Highlights arguments in function calls, which are not used by that function.
- Kommentar um die Warnung zu unterdrücken:
# bashsupport disable=BP2002
Non-constant path of source directive
BashSupport Pro can’t follow dynamic path values.
For example, "$PWD/included.sh"
is a dynamic value.
BashSupport Pro needs help here to understand which file should be used.
It supports ShellCheck source directives.
- Kommentar um die Warnung zu unterdrücken:
# shellcheck disable=SC1090
Missing source file
Highlights file path values of source
commands, which can’t be found on disk.
- Kommentar um die Warnung zu unterdrücken:
# shellcheck disable=SC1091
Modification of a read-only variable
Highlights modifications of variables, which were declared as read-only.
Commands like readonly
and declare -r
mark a variable as read-only.
Operations, which don’t modify the value, e.g. export myVar
, are not highlighted.
- Kommentar um die Warnung zu unterdrücken:
# bashsupport disable=BP3002
Incompatible line separators
Highlights files, which have line endings incompatible with Bash.
- Kommentar um die Warnung zu unterdrücken:
# bashsupport disable=BP1003
ShellCheck
Display the messages of ShellCheck in the editor.
ShellCheck is a shell script static analysis tool. It’s available at https://github.com/koalaman/shellcheck.
Function keyword
Marks a function keyword in POSIX shell scripts.
The function
keyword is non-standard in POSIX shell and only supported by Bash and other shells with extended functionality.
- Kommentar um die Warnung zu unterdrücken:
# bashsupport disable=BP2003
File with shebang is not executable
Displays a warning for files, which have a shebang, but are not executable.
A quick fix is provided to make the file executable.
Diese Inspection ist standardmäßig ausgeschaltet.
- Kommentar um die Warnung zu unterdrücken:
# bashsupport disable=BP1001
Executable file without shebang
Displays a warning for executable files, which don’t have a shebang.
A quick fix is provided to remove the executable flag of the file.
Diese Inspection ist standardmäßig ausgeschaltet.
- Kommentar um die Warnung zu unterdrücken:
# bashsupport disable=BP1002
Unresolved variable
Highlights unresolved variables in shell scripts.
A variable reference is highlighted as unresolved under these conditions:
- it was not previously declared in the file, in a sourced file or in a file sourcing the file containing the reference
- it’s not a built-in or predefined variable. For example
$PATH
is a built-in variable and$HOME
is a predefined variable. - it’s not included in the list of project variables
- Kommentar um die Warnung zu unterdrücken:
# shellcheck disable=SC2154
Google Quellcode-Stilanleitung
Missing main() function
Marks the first top-level command of a file, which should have a main()
function instead.
- Pfad:
- BashSupport Pro → Google Shell Style Guide
- Kommentar um die Warnung zu unterdrücken:
# bashsupport disable=BP5001
Incorrect main() declaration
Marks incorrectly declared main()
functions.
- Pfad:
- BashSupport Pro → Google Shell Style Guide
- Kommentar um die Warnung zu unterdrücken:
# bashsupport disable=BP5009
Inconsistent function keyword usage
Detect functions, which use the function keyword inconsistently.
- Pfad:
- BashSupport Pro → Google Shell Style Guide
- Kommentar um die Warnung zu unterdrücken:
# bashsupport disable=BP5002
Inconsistent function parentheses usage
Detect functions, which use the parentheses after the name inconsistently.
- Pfad:
- BashSupport Pro → Google Shell Style Guide
- Kommentar um die Warnung zu unterdrücken:
# bashsupport disable=BP5003
File name style
Detect files with names, which don’t follow the style guide. File names have to be lowercase with underscores to separate words.
- Pfad:
- BashSupport Pro → Google Shell Style Guide
- Kommentar um die Warnung zu unterdrücken:
# bashsupport disable=BP5004
Function name style
Detect functions with names, which don’t follow the style guide. Function have to be lowercase with underscores to separate words.
Separate library name and function name with ::
, e.g. library::myFunction
.
- Pfad:
- BashSupport Pro → Google Shell Style Guide
- Kommentar um die Warnung zu unterdrücken:
# bashsupport disable=BP5005
Variable name style
Detects variables and variable definitions with names, which don’t follow the style guide. Variables have to be lowercase with underscores to separate words.
- Pfad:
- BashSupport Pro → Google Shell Style Guide
- Kommentar um die Warnung zu unterdrücken:
# bashsupport disable=BP5006
Shebang definition
Detects incorrectly defined shebang lines.
Executables must start with #!/bin/bash
and a minimum number of flags.
- Pfad:
- BashSupport Pro → Google Shell Style Guide
- Kommentar um die Warnung zu unterdrücken:
# bashsupport disable=BP5007
Function comments
Detect functions with a missing function comment.
- Pfad:
- BashSupport Pro → Google Shell Style Guide
- Kommentar um die Warnung zu unterdrücken:
# bashsupport disable=BP5008
bats-core
Duplicate bats-core test
A single .bats
bats-core file must not contain multiple tests of the same name.
- Pfad:
- BashSupport Pro → bats-core
- Kommentar um die Warnung zu unterdrücken:
# bashsupport disable=BP6001