-
-
Notifications
You must be signed in to change notification settings - Fork 27
/
elsa-ruleset.el
58 lines (43 loc) · 1.94 KB
/
elsa-ruleset.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
(require 'eieio)
(eval-and-compile (setq eieio-backward-compatibility nil))
(require 'elsa-check)
(require 'elsa-rules-list)
(defclass elsa-ruleset () () :abstract t)
(cl-defgeneric elsa-ruleset-load (this)
"Load a ruleset.")
(defclass elsa-ruleset-dead-code (elsa-ruleset) ())
(cl-defmethod elsa-ruleset-load ((this elsa-ruleset-dead-code))
(add-to-list 'elsa-checks (elsa-check-if-useless-condition))
(add-to-list 'elsa-checks (elsa-check-cond-useless-condition))
(add-to-list 'elsa-checks (elsa-check-or-unreachable-code))
(add-to-list 'elsa-checks (elsa-check-unreachable-code))
)
(defclass elsa-ruleset-style (elsa-ruleset) ())
(cl-defmethod elsa-ruleset-load ((this elsa-ruleset-style))
(add-to-list 'elsa-checks (elsa-check-if-useless-then-progn))
(add-to-list 'elsa-checks (elsa-check-if-useless-else-progn))
(add-to-list 'elsa-checks (elsa-check-if-to-when))
(add-to-list 'elsa-checks (elsa-check-lambda-eta-conversion))
(add-to-list 'elsa-checks (elsa-check-symbol-naming))
(add-to-list 'elsa-checks (elsa-check-public-functions-have-docstring))
)
(defclass elsa-ruleset-error (elsa-ruleset) ())
(cl-defmethod elsa-ruleset-load ((this elsa-ruleset-error))
(add-to-list 'elsa-checks (elsa-check-error-message))
)
(defclass elsa-ruleset-variables (elsa-ruleset) ())
(cl-defmethod elsa-ruleset-load ((this elsa-ruleset-variables))
(add-to-list 'elsa-checks (elsa-check-unbound-variable))
)
(defclass elsa-ruleset-functions (elsa-ruleset) ())
(cl-defmethod elsa-ruleset-load ((this elsa-ruleset-functions))
(add-to-list 'elsa-checks (elsa-check-useless-type-guard))
)
(defclass elsa-ruleset-default (elsa-ruleset) ())
(cl-defmethod elsa-ruleset-load ((this elsa-ruleset-default))
(elsa-ruleset-load (elsa-ruleset-dead-code))
(elsa-ruleset-load (elsa-ruleset-style))
(elsa-ruleset-load (elsa-ruleset-error))
(elsa-ruleset-load (elsa-ruleset-functions))
(elsa-ruleset-load (elsa-ruleset-variables)))
(provide 'elsa-ruleset)