shellcheck icon indicating copy to clipboard operation
shellcheck copied to clipboard

Is there a way to include specific rules and not have to exclude all the others?

Open ader1990 opened this issue 6 years ago • 7 comments

ader1990 avatar Nov 19 '18 17:11 ader1990

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.

ader1990 avatar Nov 19 '18 17:11 ader1990

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.

koalaman avatar Nov 25 '18 05:11 koalaman

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.

ader1990 avatar Nov 25 '18 16:11 ader1990

Here's an example that only shows SC2086 quoting warnings in a file:

shellcheck -f json myfile.sh | jq '.[] | select(.code == 2086)'

koalaman avatar Nov 25 '18 18:11 koalaman

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

TinCanTech avatar Dec 12 '18 17:12 TinCanTech

This seems to be a duplicate of #837 and fixed with the introduction of the --include option in v0.7.1.

wraugh avatar Dec 19 '20 13:12 wraugh

You can

  • limit the input to Posix sh, or GNU bash (or ksh or dash)
  • output only errors (errors + warnings), and not info or style suggestions
  • include specific checks

Example

shellcheck --shell=bash --severity=error -i 2086,SC1029

coolaj86 avatar Aug 21 '22 04:08 coolaj86