Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lowercase variable name causes false positive shellcheck warning #53

Closed
bigwheel opened this issue Sep 24, 2021 · 3 comments
Closed

lowercase variable name causes false positive shellcheck warning #53

bigwheel opened this issue Sep 24, 2021 · 3 comments
Labels
bug Something isn't working false-positive False positive

Comments

@bigwheel
Copy link

bigwheel commented Sep 24, 2021

minimum reproducing example

on: push
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - run: echo "$FOO"
        env:
          FOO: FOO
      - run: echo "$bar"
        env:
          bar: bar
❯ actionlint testdata/examples/shellcheck_integration.yaml
testdata/examples/shellcheck_integration.yaml:9:9: shellcheck reported issue in this script: SC2154:warning:1:7: bar is referenced but not assigned [shellcheck]
  |
9 |       - run: echo "$bar"
  |         ^~~~


❯ cat /etc/os-release
NAME="Ubuntu"
VERSION="21.04 (Hirsute Hippo)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 21.04"
VERSION_ID="21.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=hirsute
UBUNTU_CODENAME=hirsute


❯ actionlint --version
1.6.4
installed by downloading from release page
built with go1.17.1 compiler for linux/amd64

What's happen

Actionlint doesn't give env:, jobs.<job_id>.env or jobs.<job_id>.steps[*].env to shellcheck.
And shellcheck skips variable unassigned check only if it doesn't contains lowercase.

Solution candidate

  1. Generate variable assign code by env:, jobs.<job_id>.env and jobs.<job_id>.steps[*].env then prepend it to the run script.
  2. Ignore SC2154 (option) and write this limitation in README
@rhysd rhysd added the false-positive False positive label Oct 1, 2021
@rhysd
Copy link
Owner

rhysd commented Oct 1, 2021

I'm sorry for late response. I was focusing on other project.

@rhysd rhysd closed this as completed in 545ead9 Oct 1, 2021
@rhysd rhysd added the bug Something isn't working label Oct 1, 2021
@bigwheel
Copy link
Author

bigwheel commented Oct 1, 2021

@rhysd Thanks responsible response!

@rhysd
Copy link
Owner

rhysd commented Oct 9, 2021

This fix was released at v1.6.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working false-positive False positive
Projects
None yet
Development

No branches or pull requests

2 participants