You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ shellcheck myscript
Line 2:
foo() { bar; baz; bang; biff; bow; }
^-- SC2317 (info): Command appears to be unreachable. Check usage (or ignore if invoked indirectly).
^-- SC2317 (info): Command appears to be unreachable. Check usage (or ignore if invoked indirectly).
^-- SC2317 (info): Command appears to be unreachable. Check usage (or ignore if invoked indirectly).
^-- SC2317 (info): Command appears to be unreachable. Check usage (or ignore if invoked indirectly).
^-- SC2317 (info): Command appears to be unreachable. Check usage (or ignore if invoked indirectly).
Here's what I wanted or expected to see:
It's debatable whether this should trigger at all, but clearly there's no reason for this finding to trigger on every command in an unreachable code path. This generates a lot of noise and makes it hard to tell which findings are actionable.
In this case foo is what's actually not being reached, not (just) the individual commands withinfoo. So it would be even better to flag a case like this as "foo appears unused" rather than "the contents of foo appear unreachable".
The text was updated successfully, but these errors were encountered:
It's not even correct, is it? It's not an unreachable function, it's an unused function. Which is fine, isn't it?
e.g. if we have a template, that always has a 'pr_info', 'pr_error' function, and in a script, it doesn't have one of those, is that an error? a warning? gcc treats unreachable functions as a warning, this is true, but then we also have the __maybe_unused.
I'm all for telling the user of unreachable codepaths (you did something not so smart, this code can not ever be executed), vs 'you have an unused function'. One is (potentially) an error, the other at the most a warning.
I'd be in favor in splitting these two cases, and probably not even care about unused functions, but at least unused functions (or supporting the '__may_be_unused' flag).
For bugs
shellcheck --version
or "online"):Here's a snippet or screenshot that shows the problem:
Here's what shellcheck currently says:
Here's what I wanted or expected to see:
It's debatable whether this should trigger at all, but clearly there's no reason for this finding to trigger on every command in an unreachable code path. This generates a lot of noise and makes it hard to tell which findings are actionable.
In this case
foo
is what's actually not being reached, not (just) the individual commands withinfoo
. So it would be even better to flag a case like this as "foo
appears unused" rather than "the contents offoo
appear unreachable".The text was updated successfully, but these errors were encountered: