Summary
bashrs reports false positive warnings for two common patterns that are intentional and correct.
Reproduction
Script 1: ground_truth_config.sh (sourced config)
#!/bin/bash
set -euo pipefail
MODEL_SIZE="${1:-tiny}"
case "$MODEL_SIZE" in
tiny)
WAPR_MODEL='models/whisper-tiny.apr'
;;
esac
export WAPR_MODEL
Script 2: ground_truth_test.sh (sources config, uses heredoc)
#!/bin/bash
set -euo pipefail
source "$(dirname "$0")/ground_truth_config.sh" "$MODEL_SIZE"
# Uses sourced variable - triggers SC2154
echo "Model: $WAPR_MODEL"
# Heredoc with intentional variable expansion - triggers SC2140
uv run --with torch - <<PYTHON
model = whisper.load_model("${MODEL_SIZE}")
PYTHON
Expected Behavior
- SC2154: No warning for variables set by
source command
- SC2140: No warning for heredoc variable expansion when quotes are intentional
Actual Behavior
SC2154: WAPR_MODEL is referenced but not assigned
SC2140: Word is of the form "A"B"C" (B indicated). Did you mean "ABC" or "A\"B\"C"?
Suggested Solutions
- SC2154: Track variables through
source/. commands (complex) OR provide directive to suppress
- SC2140: Recognize heredoc context where shell expansion is intentional
Workaround
Added comments documenting expected warnings:
# bashrs lint: SC2154 warnings expected (vars from sourced config)
# bashrs lint: SC2140 warnings expected (heredoc var expansion is intentional)
Environment
- bashrs version: latest
- OS: Linux
Summary
bashrs reports false positive warnings for two common patterns that are intentional and correct.
Reproduction
Script 1:
ground_truth_config.sh(sourced config)Script 2:
ground_truth_test.sh(sources config, uses heredoc)Expected Behavior
sourcecommandActual Behavior
Suggested Solutions
source/.commands (complex) OR provide directive to suppressWorkaround
Added comments documenting expected warnings:
Environment