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

Please separate the issue of unused functions from SC2317 (Command appears to be unreachable) #2966

Closed
2 tasks done
ale5000-git opened this issue Apr 10, 2024 · 11 comments
Closed
2 tasks done

Comments

@ale5000-git
Copy link

ale5000-git commented Apr 10, 2024

For bugs

Here's a snippet or screenshot that shows the problem:

Script: https://github.com/micro5k/microg-unofficial-installer/blob/ecf1f9b/utils/device-info.sh

Here's what shellcheck currently says:

[Line 882:](javascript:setPosition(882, 3))
  adb 1> /dev/null 2>&1 shell '
  ^-- [SC2317](https://www.shellcheck.net/wiki/SC2317) (info): Command appears to be unreachable. Check usage (or ignore if invoked indirectly).

Here's what I wanted or expected to see:

Function is unused.

Edit: Updated.

@brother
Copy link
Collaborator

brother commented Apr 11, 2024

This bug only happens on https://www.shellcheck.net/ but not on the release.

Bug present at d80fdfa9e8e as well as the current HEAD (04a8624).

not sure what version "but not on the release." refers to, probably something before 0.10.0 as that falls between the two hashes above and both those show the same output locally.

@ale5000-git
Copy link
Author

I have tried v0.10.0 on Windows and I didn't get any "info".

@ale5000-git
Copy link
Author

So there 2 possibilities:

  1. The bug doesn't happen on Windows, or
  2. Dataflow Analysis is never active on Windows even when specifically asked.

@brother
Copy link
Collaborator

brother commented Apr 12, 2024

Interesting.
Did you get other info lines? (maybe the severity setting is passed somewhere?).

@ale5000-git
Copy link
Author

Sorry, I had an rc file in my repository and didn't remember it.

Now with --norc I get:
Version 0.8.0 => OK
Version 0.9.0 => issue
Version 0.10.0 => issue

@koalaman
Copy link
Owner

The line does appear to be unreachable, but ShellCheck should probably still not warn about uninvoked functions.

@ale5000-git
Copy link
Author

Just noticed now that all infos refer to the unused function.

In my opinion there should be a separate SC code (with a more clear message) for the unused functions (and just one per function).

@brother
Copy link
Collaborator

brother commented Apr 15, 2024

@ale5000-git maybe you can clean up the original report here and retitle the issue to make it to the point?

or close and open new if that's preferred.

@ale5000-git ale5000-git changed the title False positive of SC2317 (Command appears to be unreachable) Please separate the issue of unused functions from SC2317 (Command appears to be unreachable) Apr 15, 2024
@stevecj
Copy link

stevecj commented Apr 18, 2024

I am actually seeing Command appears to be unreachable. for every line in a function that actually is called from later in the script. The lines that call the function are reachable, and shellcheck does not claim otherwise. I am running v0.10.0.

@ale5000-git
Copy link
Author

@stevecj
Yours is a separate issue, also you need to post an example otherwise he cannot know why it happens.

@koalaman
Copy link
Owner

koalaman commented May 4, 2024

Unreachable functions now have a separate SC2329, and unreachable commands within them will no longer emit SC2317. This also fixes x=$(y) getting two separate SC2317, one for the assignment and one for the command in the substitution. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants