This repository has been archived by the owner on Jun 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathlint381.el
64 lines (50 loc) · 2.17 KB
/
lint381.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
;;; lint381.el --- style check your code according to EECS381 style guidelines
;;; Commentary:
;; This package allows you to filter code through lint381 to warn you about
;; potential violations of the EECS 381 style guidelines. This is done through
;; flycheck, so if you don't have that installed, get to that first.
;; see https://github.com/arxanas/lint381,
;; http://www.umich.edu/~eecs381/handouts/C_Coding_Standards.pdf,
;; and http://www.umich.edu/~eecs381/handouts/C++_Coding_Standards.pdf
;; Ensure the directory of this file is in your `load-path' and add
;;
;; (require 'lint381)
;;
;; to your .emacs configuration.
;; you will likely want to add a c-mode hook in which you define the language
;; used to be c. The following should suffice:
;;
;; (setq flycheck-lint381-language "c")
;;; Notes:
;; The writer of this file assumes that if you're using this, you're
;; probably also using cppcheck. If this is not the case, you will need
;; to add some further config. The following should work:
;; ; replace <checker> with whatever you're using. If you're only doing
;; ; compilation checks it will likely be c/c++-clang or c/c++-gcc. If you're
;; ; doing any sort of further static analyis, it's probably best to use that.
;;
;; (flycheck-add-next-checker '<checker> '(warning . c/c++-lint381))
;;; Code:
(require 'flycheck)
(defgroup lint381 nil
"Style check code using lint381."
:group 'tools)
(flycheck-define-checker c/c++-lint381
"A c++ style checker based on the lint381 tool.
See URL `https://github.com/arxanas/lint381'."
:command ("lint381"
(option "--lang=" flycheck-lint381-language concat)
source)
:error-patterns
((warning line-start (file-name) ":" line ":" column ": error: " (message)
line-end))
:modes (c++-mode c-mode))
(flycheck-def-option-var flycheck-lint381-language "cpp" c/c++-lint381
"The language to use for the linter.
Valid options are c and cpp , defaulting to cpp"
:group 'clang-format
:type 'string)
(make-variable-buffer-local 'flycheck-lint381-language)
(flycheck-add-next-checker 'c/c++-cppcheck '(warning . c/c++-lint381))
(add-to-list 'flycheck-checkers 'c/c++-lint381 'append)
(provide 'lint381)