Skip to content
Permalink
Browse files

[Fix #499] Add option to exclude ShellCheck warnings

  • Loading branch information...
lunaryorn committed Oct 20, 2014
1 parent dc7fb06 commit 40469d58728a00cf0db18e487f1482c2a92245f0
Showing with 32 additions and 3 deletions.
  1. +5 −0 doc/guide/languages.rst
  2. +18 −3 flycheck.el
  3. +9 −0 test/flycheck-test.el
@@ -639,6 +639,11 @@ Shell script languages
.. flyc-checker:: sh-shellcheck
:auto:

.. rubric:: Options

.. option:: flycheck-shellcheck-excluded-warnings
:auto:

.. _POSIX Shell Command Language: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html
.. _GNU Bash POSIX Mode: http://www.gnu.org/software/bash/manual/html_node/Bash-POSIX-Mode.html#Bash-POSIX-Mode

@@ -6260,14 +6260,29 @@ See URL `http://www.zsh.org/'."
:next-checkers ((warning . sh-shellcheck)))

(defconst flycheck-shellcheck-supported-shells '(bash ksh88 sh zsh)
"Shells supported by Shellcheck.")
"Shells supported by ShellCheck.")

(flycheck-def-option-var flycheck-shellcheck-excluded-warnings nil sh-shellcheck
"A list of excluded warnings for ShellCheck.
The value of this variable is a list of strings, where each
string is a warning code to be excluded from ShellCheck reports.
By default, no warnings are excluded."
:type '(repeat :tag "Excluded warnings"
(string :tag "Warning code"))
:safe #'flycheck-string-list-p
:package-version '(flycheck . "0.21"))

(flycheck-define-checker sh-shellcheck
"A shell script syntax and style checker using Shellcheck.
See URL `https://github.com/koalaman/shellcheck/'."
:command ("shellcheck" "-f" "gcc"
"-s" (eval (symbol-name sh-shell))
:command ("shellcheck"
;; Use GCC output format to have the warning code in the messages
"--format" "gcc"
"--shell" (eval (symbol-name sh-shell))
(option "--exclude" flycheck-shellcheck-excluded-warnings list
flycheck-option-comma-separated-list)
source)
:modes sh-mode
:error-patterns
@@ -5367,6 +5367,15 @@ Why not:
'(3 7 error "Double quote array expansions, otherwise they're like $* and break on spaces. [SC2068]"
:checker sh-shellcheck)))

(ert-deftest flycheck-define-checker/sh-shellcheck-excluded-warning ()
:tags '(builtin-checker external-tool language-sh)
(skip-unless (flycheck-check-executable 'sh-shellcheck))
(let ((flycheck-shellcheck-excluded-warnings '("SC2088")))
(flycheck-test-should-syntax-check
"checkers/sh-shellcheck.sh" 'sh-mode
'(3 7 error "Double quote array expansions, otherwise they're like $* and break on spaces. [SC2068]"
:checker sh-shellcheck))))

(ert-deftest flycheck-define-checker/slim ()
:tags '(builtin-checker external-tool language-slim)
(skip-unless (flycheck-check-executable 'slim))

0 comments on commit 40469d5

Please sign in to comment.
You can’t perform that action at this time.