koalaman / shellcheck

ShellCheck, a static analysis tool for shell scripts
https://www.shellcheck.net
GNU General Public License v3.0
36.15k stars 1.77k forks source link

Grouping and ranking warnings #495

Open kurahaupo opened 8 years ago

kurahaupo commented 8 years ago

In #464 and elsewhere it's noted that some warnings should be disabled on a whole-of-source basis because they're essentially trying to catch "newby errors", or because you're doing something unusual like running a custom version of [ instead of the built-in one. It would make sense if that could be embedded in the file rather than requiring a command-line option, or having to be repeated at each location where it's otherwise triggered.

That led me to thinking about two related options:

In particular, "posix" and "better than posix" would be effectively mutually contradictory, so you'd only want one or the other. (Currently this would be selected based on the shebang line; it'd be nice to be explicit about it.)

Select coverage of a warning:

# shellcheck disable SC1007               # applies to the next line
# shellcheck lines 5 disable SC1007       # applies to the next 5 lines
# shellcheck scope disable SC1007         # applies to end of current compound command
# shellcheck global disable SC1007        # applies to rest of file

Select warnings by type or class:

# shellcheck global enable special-[      # rules where [ is treated as a special built-in
# shellcheck global enable posix          # warnings about lack of POSIX compliance
# shellcheck global enable bash           # suggestions where Bash has better ways
                                          # of doing things, like [[ instead of [
# shellcheck global enable assignment     # warnings about variable assignments
# shellcheck global enable arithmetic     # warnings about arithmetic context

Select warnings by strength or rank:

# shellcheck global quiet                 # approximately the same as "disable all"
# shellcheck global normal
# shellcheck global nitpick
# shellcheck global lint

Allow combinations in one line:

# shellcheck global disable all enable errors enable redirection enable
dcpc007 commented 6 years ago

I upvote this one too. Need this to implement Gitlab CI automated checks. --> "Select warnings by strength or rank"