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

Many shellcheck complains #304

Closed
bdrung opened this issue May 21, 2024 · 7 comments
Closed

Many shellcheck complains #304

bdrung opened this issue May 21, 2024 · 7 comments
Labels
bug Our bugs

Comments

@bdrung
Copy link
Contributor

bdrung commented May 21, 2024

Running make syncheck on Ubuntu 24.04 on the source code shows a lot of shellcheck complains, including:

  • SC2086 (info): Double quote to prevent globbing and word splitting.
  • SC2317 (info): Command appears to be unreachable. Check usage (or ignore if invoked indirectly).

Remaining output after disabling those two:

$ make syncheck
shellcheck $(shfmt -f .)

In dracut.sh line 1382:
        && dracut_args[$i]="\"${dracut_args[$i]}\""
                       ^-- SC2004 (style): $/${} is unnecessary on arithmetic variables.


In modules.d/80lvmthinpool-monitor/start-thinpool-monitor.sh line 12:
    [ -n "$_lvm2_thin_device" ] && return $?
                                          ^-- SC2319 (warning): This $? refers to a condition, not a command. Assign to a variable to avoid it being overwritten.


In modules.d/95iscsi/iscsiroot.sh line 232:
    [ -z "$targets" ] && warn "Target discovery to $iscsi_target_ip:${iscsi_target_port:+$iscsi_target_port} failed with status $?" && return 1
                                                                                                                                ^-- SC2319 (warning): This $? refers to a condition, not a command. Assign to a variable to avoid it being overwritten.

For more information:
  https://www.shellcheck.net/wiki/SC2319 -- This $? refers to a condition, no...
  https://www.shellcheck.net/wiki/SC2004 -- $/${} is unnecessary on arithmeti...
make: *** [Makefile:239: syncheck] Fehler 1
@bdrung bdrung added the bug Our bugs label May 21, 2024
@LaszloGombos
Copy link
Collaborator

Thanks @bdrung . Somewhat expected, but good to have a bug for it.
CC @jamacku

@bdrung
Copy link
Contributor Author

bdrung commented May 21, 2024

Do we run shellcheck on the CI?

@LaszloGombos
Copy link
Collaborator

Do we run shellcheck on the CI?

Yes we do. #75 . Only differential. And some warnings are disabled - https://github.com/dracut-ng/dracut-ng/blob/main/.shellcheckrc

@jamacku
Copy link
Contributor

jamacku commented May 22, 2024

This is somewhat expected. make syncheck calls regular shellcheck, but upstream uses a GitHub workflow that runs differential scans of ShellCheck and reports only newly added defects caused by changes from PR or commit.

Once a PR is merged, defects are considered false positives since they went through review. However, maintainers have access to all defects in the Security tab in the GitHub UI.

I'm currently working on making differential ShellCheck available as CLI and possibly packaged in distributions (redhat-plumbers-in-action/differential-shellcheck#179, redhat-plumbers-in-action/differential-shellcheck#396). Then you could use it in make syncheck as well.

@bdrung
Copy link
Contributor Author

bdrung commented Jun 14, 2024

I submitted a bunch of merge requests to address shellcheck complains. Current status: after applying all my open merge requests, there are five SC2086 plus a all (a lot) SC2317 complains left. I'll address the remaining SC2086 soon. Then only SC2317 will be left. So make syncheck could be run on all merge requests then.

@bdrung
Copy link
Contributor Author

bdrung commented Jun 22, 2024

I submitted some more merge requests to address shellcheck complains. Current status: Only four SC2317 complains left.

@bdrung
Copy link
Contributor Author

bdrung commented Jun 25, 2024

All shellcheck complains are fixed now. make syncheck is happy on the current main branch (commit cc5e8d6).

@bdrung bdrung closed this as completed Jun 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Our bugs
Projects
None yet
Development

No branches or pull requests

3 participants