bio-miga/miga

View on GitHub
scripts/cds.bash

Summary

Maintainability
Test Coverage

$/${} is unnecessary on arithmetic variables.
Open

      if [[ $C_LEN -gt $(($P_LEN * 11 / 10)) ]] ; then
Severity: Minor
Found in scripts/cds.bash by shellcheck

$/${} is unnecessary on arithmetic variables.

Problematic code:

echo $(($n+1))

Correct code:

echo $((n+1))

Rationale:

The $ on regular variables in arithmetic contexts is unnecessary, and can even lead to subtle bugs. This is because the contents of $((..)) is first expanded into a string, and then evaluated as an expression:

$ a='1+1'
$ echo $(($a * 5))    # becomes 1+1*5
6
$ echo $((a * 5))     # evaluates as (1+1)*5
10

The $ is unavoidable for special variables like $1 vs 1, $# vs #. It's also required when adding modifiers to parameters expansions, like ${#var} or ${var%-}. ShellCheck does not warn about these cases.

Notice

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

There are no issues that match your filters.

Category
Status