Skip to content
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

.. rubric:: Options

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

.. _POSIX Shell Command Language:
.. _GNU Bash POSIX Mode:

@@ -6260,14 +6260,29 @@ See URL `'."
: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 `'."
: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
:modes sh-mode
@@ -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")))
"checkers/" '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.