-
Notifications
You must be signed in to change notification settings - Fork 5
/
flycheck-credo.el
84 lines (66 loc) · 2.85 KB
/
flycheck-credo.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
;;; flycheck-credo.el --- flycheck checker for elixir credo
;; Copyright (C) 2016 by Aaron Jensen
;; Author: Aaron Jensen <aaronjensen@gmail.com>
;; URL: https://github.com/aaronjensen/flycheck-credo
;; Version: 0.1.0
;; Package-Requires: ((flycheck "29"))
;;; Commentary:
;; This package adds support for credo to flycheck.
;; To use it, require it and ensure you have elixir-mode set up for flycheck:
;; (eval-after-load 'flycheck
;; '(flycheck-credo-setup))
;; (add-hook 'elixir-mode-hook 'flycheck-mode)
;;; License:
;; This file is not part of GNU Emacs.
;; However, it is distributed under the same license.
;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Code:
(require 'flycheck)
(defun flycheck-credo--working-directory (&rest _ignored)
"Find directory with from which we can run credo."
(and buffer-file-name
(locate-dominating-file buffer-file-name "deps/credo")))
(flycheck-def-option-var flycheck-elixir-credo-strict nil elixir-credo
"Enable strict mode in credo.
When non-nil, pass the `--strict' flag to credo."
:type 'boolean
:safe #'booleanp)
(flycheck-define-checker elixir-credo
"Elixir credo checker."
:command ("mix"
"credo"
(option-flag "--strict" flycheck-elixir-credo-strict)
"--format"
"flycheck"
"--read-from-stdin"
source-original)
:standard-input t
:predicate
(lambda () (and buffer-file-name
(locate-dominating-file buffer-file-name "deps/credo")))
:working-directory flycheck-credo--working-directory
:error-patterns
((info line-start (file-name) ":" line ":" column ": " (or "F" "R" "C") ": " (message) line-end)
(info line-start (file-name) ":" line ": " (or "F" "R" "C") ": " (message) line-end)
(warning line-start (file-name) ":" line ":" column ": " (or "D" "W") ": " (message) line-end)
(warning line-start (file-name) ":" line ": " (or "D" "W") ": " (message) line-end))
:modes (elixir-ts-mode elixir-mode))
;;;###autoload
(defun flycheck-credo-setup ()
"Setup flycheck-credo.
Add `elixir-credo' to `flycheck-checkers'."
(interactive)
(add-to-list 'flycheck-checkers 'elixir-credo t))
(provide 'flycheck-credo)
;;; flycheck-credo.el ends here