shellcheck
shellcheck copied to clipboard
Is there a way to include specific rules and not have to exclude all the others?
I could find in the docs only the -e flag, to exclude rules. is there an option to specify only the rules I desire? It's very cumbersome to find all the other hundreds of rules and check them manually and then add them to the exclusion rule.
Thanks, Adrian.
There is currently no way to do this directly (but easy to jq/grep from the json/gcc output formats). This is definitely a feature that will be added soon, since it will be very helpful for the upcoming autofix support.
Great to hear that you will be adding that, very useful tool :) Can you give me an example of how can I jq/grep from the json output? thanks.
Here's an example that only shows SC2086 quoting warnings in a file:
shellcheck -f json myfile.sh | jq '.[] | select(.code == 2086)'
On the same theme but from the other end; would you consider adding a command line option to have all rules enabled and all # shellcheck disable=*
directives be ignored. For example: shellcheck --force-enable-all myscript
This seems to be a duplicate of #837 and fixed with the introduction of the --include
option in v0.7.1.
You can
- limit the input to Posix
sh
, or GNUbash
(orksh
ordash
) - output only errors (errors + warnings), and not info or style suggestions
- include specific checks
Example
shellcheck --shell=bash --severity=error -i 2086,SC1029