shellcheck icon indicating copy to clipboard operation
shellcheck copied to clipboard

SC2329 should be transitive

Open ensc opened this issue 1 year ago • 2 comments

For bugs

  • Rule id SC2329
  • My shellcheck version (shellcheck --version or "online"): online; 0.9.0 shows similar results but for SC2317
  • [X] The rule's wiki page does not already cover this (e.g. https://shellcheck.net/wiki/SC2086)
  • [X] I tried on https://www.shellcheck.net/ and verified that this is still a problem on the latest commit

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

#! /bin/bash

note() {
    echo "$*"
}

# shellcheck disable=SC2317,SC2329
tool_a() {
    note a
}

# shellcheck disable=SC2317,SC2329
tool_b() {
    echo b
}

RC=0

for i in a b; do
    tool_"$i" || RC=1
done

exit $RC

Here's what shellcheck currently says:

[Line 3:](javascript:setPosition(3, 1))
note() {
^-- [SC2329](https://www.shellcheck.net/wiki/SC2329) (info): This function is never invoked. Check usage (or ignored if invoked indirectly).

Here's what I wanted or expected to see:

no warnings;

SC2329 should not be triggered for functions which are called by functions with disabled SC2329 check

ensc avatar Sep 06 '24 11:09 ensc

Hm. I get a different result on a Fedora 40 local vm instance: SC2317 on line 4, 'echo "$*"', "(info): Command appears unreachable...." The rpm is 'ShellCheck-0.9.0-6.fc40.x86_64'. The same output as yours on shellcheck.net, though.

Wiley

On Fri, Sep 6, 2024, 4:51 AM Enrico Scholz @.***> wrote:

For bugs

  • Rule id SC2329
  • My shellcheck version (shellcheck --version or "online"): online; 0.9.0 shows similar results but for SC2317
  • The rule's wiki page does not already cover this (e.g. https://shellcheck.net/wiki/SC2086)
  • I tried on https://www.shellcheck.net/ and verified that this is still a problem on the latest commit

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

#! /bin/bash note() { echo "$*" }

shellcheck disable=SC2317,SC2329tool_a() {

note a

}

shellcheck disable=SC2317,SC2329tool_b() {

echo b

}

RC=0 for i in a b; do tool_"$i" || RC=1done exit $RC

Here's what shellcheck currently says:

[Line 3:](javascript:setPosition(3, 1)) note() { ^-- SC2329 (info): This function is never invoked. Check usage (or ignored if invoked indirectly).

Here's what I wanted or expected to see:

no warnings;

SC2329 should not be triggered for functions which are called by functions with disabled SC2329 check

— Reply to this email directly, view it on GitHub https://github.com/koalaman/shellcheck/issues/3054, or unsubscribe https://github.com/notifications/unsubscribe-auth/AUF2F2ZN3ZS4KPZTURZYAYDZVGJL3AVCNFSM6AAAAABNYNTW56VHI2DSMVQWIX3LMV43ASLTON2WKOZSGUYTAMRVGU3DCMY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

wileyhy avatar Sep 06 '24 14:09 wileyhy

Hm. I get a different result on a Fedora 40 local vm instance: SC2317 on line 4

SC2329 seems to have been splitted off from SC2317 in recent versions (used on http://spellcheck.net, but not (yet) by Fedora 40)

ensc avatar Sep 06 '24 14:09 ensc

This should be working as described on the latest git commit, and also on shellcheck.net (which may not have been published when this issue was filed).

koalaman avatar Oct 27 '24 22:10 koalaman

I am confused that SC2329 was in some v0.9.0 commit, while it was now officially added with v0.11.0? However, with v0.11.0 and on current https://www.shellcheck.net/, the code throws the warning (again):

[Line 3:](javascript:setPosition(3, 1))
note() {
^-- [SC2329](https://www.shellcheck.net/wiki/SC2329) (info): This function is never invoked. Check usage (or ignored if invoked indirectly).

MichaIng avatar Aug 05 '25 00:08 MichaIng