It would be useful if ShellCheck could also output the URL of check wiki pages for direct research instead of only the check code.
In what context?
The web page already do link the code.
If I would get a URL in my terminal for every SC-code it would probably get rather cluttered.
The URLs of the wiki are fairly discoverable and an opportunistic link is probably not a bad a idea, there might be dead links at some point but that's rather a reason for a PR/Ticket than anything else?
Consider the following
In mailmigrate.sh line 25:
echo error: $mailbox is already on $newnode
^-- SC2086: Double quote to prevent globbing and word splitting.
^-- SC2086: Double quote to prevent globbing and word splitting.
Would then expand to something like
In mailmigrate.sh line 25:
echo error: $mailbox is already on $newnode
^-- SC2086: Double quote to prevent globbing and word splitting.
https://github.com/koalaman/shellcheck/wiki/SC2086
^-- SC2086: Double quote to prevent globbing and word splitting.
https://github.com/koalaman/shellcheck/wiki/SC2086
or maybe
In mailmigrate.sh line 25:
echo error: $mailbox is already on $newnode
^-- SC2086: Double quote to prevent globbing and word splitting. Read more in the Shellcheck wiki at https://github.com/koalaman/shellcheck/wiki/SC2086
^-- SC2086: Double quote to prevent globbing and word splitting. Read more in the Shellcheck wiki at https://github.com/koalaman/shellcheck/wiki/SC2086
Adding the information as extra stuff in the alternative formats (json, etc) is something else ofc. Being able to disable the output from standard output is something I would be glad to have at if t was added to the terminal context.
How about collecting the check codes and outputting their URLs at the end?
In mailmigrate.sh line 25:
echo error: $mailbox is already on $newnode
^-- SC2086: Double quote to prevent globbing and word splitting.
^-- SC2086: Double quote to prevent globbing and word splitting.
See detailed explanation:
https://github.com/koalaman/shellcheck/wiki/SC2086
That does seem useful.
Does anyone have opinions on format?
There's lynx -dump style:
In mailmigrate.sh line 25:
echo error: $mailbox is already on $newnode
^-- SC2086 [1]: Double quote to prevent globbing and word splitting.
^-- SC2154 [2]: foo is referenced but not assigned.
See detailed explanation:
[1] https://github.com/koalaman/shellcheck/wiki/SC2086
[2] https://github.com/koalaman/shellcheck/wiki/SC2154
...
Or using some redirector to list fewer URLs:
In mailmigrate.sh line 25:
echo error: $mailbox is already on $newnode
^-- SC2086: Double quote to prevent globbing and word splitting.
^-- SC2154: foo is referenced but not assigned.
See detailed explanations on:
http://shellcheck.net/code/SC2086,SC2153,...
Possibly in addition to limiting the list to ~3 elements by order of appearance or severity:
In mailmigrate.sh line 25:
for f in $(ls *.m3u)
^-- SC2045: Iterating over ls output is fragile. Use globs.
^-- SC2035: Use ./*glob* or -- *glob* so names with dashes won't become options.
^-- SC2062: Quote the grep pattern so the shell won't interpret it.
^-- SC2086: Double quote to prevent globbing and word splitting.
In mailmigrate.sh line 28:
&& echo -e 'Playlist $f contains a HQ file in mp3 format'
^-- SC2039: In POSIX sh, echo flags are undefined.
^-- SC2016: Expressions don't expand in single quotes, use double quotes for that.
Detailed information about top 2 errors and 1 warning:
https://github.com/koalaman/shellcheck/wiki/SC2016
https://github.com/koalaman/shellcheck/wiki/SC2039
https://github.com/koalaman/shellcheck/wiki/SC2062
The 3-element limit or lynx style are the best in my opinion. I would be satisfied with any of the three approaches though, I think.
On Fri, 2 Jun 2017, Mathias Brodala wrote:
How about collecting the check codes and outputting their URLs at the end?
You mean like:
shellcheck() {
command shellcheck "$@" > >(
tee > >(
grep -oE 'SC[[:digit:]]+:' |
sort -u |
sed 's#^#https://github.com/koalaman/shellcheck/wiki/#'
)
)
}
(Note that 芦grep -o禄 is a GNUism, but this is Bash we're talking about.)
lynx style seems nice.
Of note, some other linters/static code analyzers will put this type of output behind a flag, such as Rubocop's -S flag. A similar approach could be followed here if wanting to preserve the default behavior as "don't display the wiki URL alongside warnings".
Hi, and put a mention in the usage/help option (shellcheck -h) too
You now get one of these at the end of TTY shellcheck output:
For more information:
https://www.shellcheck.net/wiki/SC1050 -- Expected 'then'.
https://www.shellcheck.net/wiki/SC1012 -- \n is just literal 'n' here. For line...
https://www.shellcheck.net/wiki/SC1078 -- Did you forget to close this double q...
There's additionally a flag -W to set the number, e.g. shellcheck -W 10 file. If anyone would like to hide it, they can add -W 0 to their SHELLCHECK_OPTS.
The main purpose of this is to make the wiki discoverable, since quite a few users aren't aware of it.
Thanks a lot, this looks great, looking forward to the next release. :-)
This is a great idea. I am going to change my emacs macro that adds disable directives to include the wiki link in a comment.
Most helpful comment
You now get one of these at the end of TTY shellcheck output:
There's additionally a flag
-Wto set the number, e.g.shellcheck -W 10 file. If anyone would like to hide it, they can add-W 0to theirSHELLCHECK_OPTS.The main purpose of this is to make the wiki discoverable, since quite a few users aren't aware of it.