Skip to content

Commit

Permalink
Add emacs-lisp-check-declare checker
Browse files Browse the repository at this point in the history
  • Loading branch information
darkfeline committed Jul 19, 2017
1 parent df659ee commit 2e21ec5
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
25 changes: 24 additions & 1 deletion flycheck.el
Expand Up @@ -178,6 +178,7 @@ attention to case differences."
elixir-dogma
emacs-lisp
emacs-lisp-checkdoc
emacs-lisp-check-declare
erlang-rebar3
erlang
eruby-erubis
Expand Down Expand Up @@ -7161,12 +7162,34 @@ The checker runs `checkdoc-current-buffer'."
(not (or (flycheck-autoloads-file-p)
(and (buffer-file-name)
(member (file-name-nondirectory (buffer-file-name))
'("Cask" "Carton" ".dir-locals.el")))))))
'("Cask" "Carton" ".dir-locals.el"))))))
:next-checkers (emacs-lisp-check-declare))

(dolist (checker '(emacs-lisp emacs-lisp-checkdoc))
(setf (car (flycheck-checker-get checker 'command))
flycheck-this-emacs-executable))

(defconst flycheck-emacs-lisp-check-declare-form
(flycheck-prepare-emacs-lisp-form
(unless (require 'elisp-mode nil 'no-error)
;; TODO: Fallback for Emacs 24, remove when dropping support for 24
(require 'lisp-mode))
(require 'check-declare)
(check-declare-file (car command-line-args-left))))

(flycheck-define-checker emacs-lisp-check-declare
"An Emacs Lisp style checker using ‘check-declare-file’."
:command ("emacs" (eval flycheck-emacs-args)
"--eval" (eval flycheck-emacs-lisp-check-declare-form)
"--" source)
:error-patterns
((warning line-start (file-name) ":" line ":" column
":Warning (check-declare): said\n"
(message (zero-or-more " " (zero-or-more not-newline))
(zero-or-more "\n " (zero-or-more not-newline)))
line-end))
:modes (emacs-lisp-mode))

(flycheck-def-option-var flycheck-erlang-include-path nil erlang
"A list of include directories for Erlang.

Expand Down
6 changes: 6 additions & 0 deletions test/flycheck-test.el
Expand Up @@ -3049,6 +3049,12 @@ See https://github.com/flycheck/flycheck/issues/531 and Emacs bug #19206"))
:checker emacs-lisp-checkdoc))
(remove-hook 'emacs-lisp-mode-hook disable-byte-comp))))

(flycheck-ert-def-checker-test emacs-lisp-check-declare emacs-lisp nil
(flycheck-ert-should-syntax-check
"language/emacs-lisp/check-declare-errors.el" 'emacs-lisp-mode
'(10 1 warning "`this-function-is-not-declared' was defined in\n this-file-does-not-exist.el: file not found"
:checker emacs-lisp-check-declare)))

(flycheck-ert-def-checker-test erlang erlang error
(flycheck-ert-should-syntax-check
"language/erlang/erlang/error.erl" 'erlang-mode
Expand Down
13 changes: 13 additions & 0 deletions test/resources/language/emacs-lisp/check-declare-errors.el
@@ -0,0 +1,13 @@
;;; check-declare-errors.el -- check-declare errors -*- lexical-binding: t; -*-

;;; Commentary:

;; Checkdoc uses the syntax table and comment syntax of the current buffer; if
;; not set properly, it gets confused by the code below.

;;; Code:

(declare-function this-function-is-not-declared "/this-file-does-not-exist.el")

(provide 'check-declare-errors)
;;; check-declare-errors.el ends here

0 comments on commit 2e21ec5

Please sign in to comment.