Skip to content

Commit c71a576

Browse files
committed
disable shellcheck rule SC2043 (fix #355)
because it is reported as the result of placeholder replacement. ``` - run: | for elem in ${{ inputs.foo }}; do echo "$elem" done ```
1 parent b7ebeb4 commit c71a576

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

rule_shellcheck.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,9 @@ func (rule *RuleShellcheck) runShellcheck(src, shell string, pos *Pos) {
187187
// so this rule can cause false positives (#53).
188188
// - SC2157: Argument to -z is always false due to literal strings. When the argument of -z is replaced from ${{ }},
189189
// this can happen. For example, `if [ -z ${{ env.FOO }} ]` -> `if [ -z ______________ ]` (#113).
190-
args := []string{"--norc", "-f", "json", "-x", "--shell", sh, "-e", "SC1091,SC2194,SC2050,SC2154,SC2157", "-"}
190+
// - SC2043: Loop can be detected as only running once when the target of iteration is a placeholder. (#355)
191+
// e.g. `for foo in ${{ inputs.foo }}; do`
192+
args := []string{"--norc", "-f", "json", "-x", "--shell", sh, "-e", "SC1091,SC2194,SC2050,SC2154,SC2157,SC2043", "-"}
191193
rule.Debug("%s: Running %s command with %s", pos, rule.cmd.exe, args)
192194

193195
// Use same options to run shell process described at document
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
on: push
2+
jobs:
3+
test:
4+
runs-on: ubuntu-latest
5+
steps:
6+
- run: |
7+
for x in ${{ github.run_number }}; do
8+
echo "$x"
9+
done

0 commit comments

Comments
 (0)