codeclimate/codeclimate

View on GitHub
codeclimate-wrapper

Summary

Maintainability
Test Coverage

Expressions don't expand in single quotes, use double quotes for that.
Open

    'test -n "$DOCKER_HOST" -a "$DOCKER_HOST" != "unix:///var/run/docker.sock"' > /dev/null 2>&1 \
Severity: Minor
Found in codeclimate-wrapper by shellcheck

Expressions don't expand in single quotes, use double quotes for that.

Problematic code:

name=World
echo 'Hello $name'

Correct code:

name=World
echo "Hello $name"

Rationale:

Single quotes prevent expansion of everything, including variables and command substitution.

If you want to use the values of variables and such, use double quotes instead.

Note that if you have other items that needs single quoting, you can use both in a single word:

echo '$1 USD is '"$rate GBP"

Exceptions

If you want $stuff to be a literal dollar sign followed by the characters "stuff", you can [[ignore]] this message.

ShellCheck tries to be smart about it, and won't warn when this is used with awk, perl and similar, but there are some inherent ambiguities like 'I have $1 in my wallet', which could be "one dollar" or "whatever's in the first parameter".

In the particular case of sed, ShellCheck uses additional heuristics to try to separate cases like 's/$foo/bar/' (failing to replace the variable $foo) with from the false positives like '$d' (delete last line). If you're still triggering these, consider being more generous with your spaces: use $ { s/foo/bar; } instead of ${s/foo/bar/;}

Notice

Original content from the ShellCheck https://github.com/koalaman/shellcheck/wiki.

Use single quotes, otherwise this expands now rather than when signalled.
Open

  trap "rm '$stdin_stash'" EXIT
Severity: Minor
Found in codeclimate-wrapper by shellcheck

Use single quotes, otherwise this expands now rather than when signalled.

Problematic code:

trap "echo \"Finished on $(date)\"" EXIT

Correct code:

trap 'echo "Finished on $(date)"' EXIT

Rationale:

With double quotes, all parameter and command expansions will expand when the trap is defined rather than when it's executed.

In the example, the message will contain the date on which the trap was declared, and not the date on which the script exits.

Using single quotes will prevent expansion at declaration time, and save it for execution time.

Exceptions

If you don't care that the trap code is expanded early because the commands/variables won't change during execution of the script, or because you want to use the current and not the future values, then you can ignore this message.

Notice

Original content from the ShellCheck https://github.com/koalaman/shellcheck/wiki.

Use single quotes, otherwise this expands now rather than when signalled.
Open

    trap "rm -rf '$tmp_source_dir'" EXIT
Severity: Minor
Found in codeclimate-wrapper by shellcheck

Use single quotes, otherwise this expands now rather than when signalled.

Problematic code:

trap "echo \"Finished on $(date)\"" EXIT

Correct code:

trap 'echo "Finished on $(date)"' EXIT

Rationale:

With double quotes, all parameter and command expansions will expand when the trap is defined rather than when it's executed.

In the example, the message will contain the date on which the trap was declared, and not the date on which the script exits.

Using single quotes will prevent expansion at declaration time, and save it for execution time.

Exceptions

If you don't care that the trap code is expanded early because the commands/variables won't change during execution of the script, or because you want to use the current and not the future values, then you can ignore this message.

Notice

Original content from the ShellCheck https://github.com/koalaman/shellcheck/wiki.

Expressions don't expand in single quotes, use double quotes for that.
Invalid

    && invalid_docker_host "$(docker-machine ssh "$DOCKER_MACHINE_NAME" -- 'echo "$DOCKER_HOST"')"
Severity: Minor
Found in codeclimate-wrapper by shellcheck

Expressions don't expand in single quotes, use double quotes for that.

Problematic code:

name=World
echo 'Hello $name'

Correct code:

name=World
echo "Hello $name"

Rationale:

Single quotes prevent expansion of everything, including variables and command substitution.

If you want to use the values of variables and such, use double quotes instead.

Note that if you have other items that needs single quoting, you can use both in a single word:

echo '$1 USD is '"$rate GBP"

Exceptions

If you want $stuff to be a literal dollar sign followed by the characters "stuff", you can [[ignore]] this message.

ShellCheck tries to be smart about it, and won't warn when this is used with awk, perl and similar, but there are some inherent ambiguities like 'I have $1 in my wallet', which could be "one dollar" or "whatever's in the first parameter".

In the particular case of sed, ShellCheck uses additional heuristics to try to separate cases like 's/$foo/bar/' (failing to replace the variable $foo) with from the false positives like '$d' (delete last line). If you're still triggering these, consider being more generous with your spaces: use $ { s/foo/bar; } instead of ${s/foo/bar/;}

Notice

Original content from the ShellCheck https://github.com/koalaman/shellcheck/wiki.

There are no issues that match your filters.

Category
Status