From d78c11361a02448dccbc3eeeeccba140037f435f Mon Sep 17 00:00:00 2001 From: XuehaiPan Date: Mon, 8 Nov 2021 23:22:49 +0800 Subject: [PATCH] .shellcheckrc: disable unneeded check SC2310-SC2312 globally --- .gitignore | 1 + .shellcheckrc | 32 ++++++++++++++++++++++++++++++++ Library/Homebrew/style.rb | 2 -- 3 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 .shellcheckrc diff --git a/.gitignore b/.gitignore index 334a06e404..dab47f44e8 100644 --- a/.gitignore +++ b/.gitignore @@ -188,6 +188,7 @@ !/.gitignore !/.yardopts !/.vale.ini +!/.shellcheckrc !/CHANGELOG.md !/CONTRIBUTING.md !/Dockerfile diff --git a/.shellcheckrc b/.shellcheckrc new file mode 100644 index 0000000000..5fb9c0db2f --- /dev/null +++ b/.shellcheckrc @@ -0,0 +1,32 @@ +# Look for 'source'd files relative to the current working directory where the +# shellcheck command is invoked. +source-path=Library + +# Allow opening any 'source'd file, even if not specified as input +external-sources=true + +# SC2310: This function is invoked in an 'if' / ! condition so set -e will be +# disabled. Invoke separately if failures should cause the script to exit. +# See: https://github.com/koalaman/shellcheck/wiki/SC2310 +# +# We don't use the `set -e` feature in Bash scripts yet. +# We do need the return status as condition for if switches. +# Allow `if command` and `if ! command`. +disable=SC2310 + +# SC2311: Bash implicitly disabled set -e for this function invocation because +# it's inside a command substitution. Add set -e; before it or enable inherit_errexit. +# See: https://github.com/koalaman/shellcheck/wiki/SC2311 +# +# We don't use the `set -e` feature in Bash scripts yet. +# We don't need return codes for "$(command)", only stdout is needed. +# Allow `var="$(command)"`, etc. +disable=SC2311 + +# SC2312: Consider invoking this command separately to avoid masking its return +# value (or use '|| true' to ignore). +# See: https://github.com/koalaman/shellcheck/wiki/SC2312 +# +# We don't need return codes for "$(command)", only stdout is needed. +# Allow `[[ -n "$(command)" ]]`, `func "$(command)"`, pipes, etc. +disable=SC2312 diff --git a/Library/Homebrew/style.rb b/Library/Homebrew/style.rb index c240798dfb..29f4647fb5 100644 --- a/Library/Homebrew/style.rb +++ b/Library/Homebrew/style.rb @@ -172,8 +172,6 @@ module Homebrew "--enable=all", "--external-sources", "--source-path=#{HOMEBREW_LIBRARY}", - # TODO: fix these - "--exclude=SC2310,SC2311,SC2312", "--", *files, ]