[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/relint 9259a5c 03/21: Check some :value parameters in d
From: |
Mattias Engdegård |
Subject: |
[elpa] externals/relint 9259a5c 03/21: Check some :value parameters in defcustom :type clauses |
Date: |
Sun, 3 May 2020 11:13:34 -0400 (EDT) |
branch: externals/relint
commit 9259a5c5e82f75aa4efd20746c6d0887acd64e0f
Author: Mattias Engdegård <address@hidden>
Commit: Mattias Engdegård <address@hidden>
Check some :value parameters in defcustom :type clauses
For example, this catches
:type '(string :value "some bad regexp")
---
relint.el | 13 +++++++------
test/1.elisp | 13 +++++++++++++
test/1.expected | 30 +++++++++++++++++++++---------
3 files changed, 41 insertions(+), 15 deletions(-)
diff --git a/relint.el b/relint.el
index bc4a9af..d484116 100644
--- a/relint.el
+++ b/relint.el
@@ -1551,12 +1551,13 @@ RANGES is a list of (X . Y) representing the interval
[X,Y]."
(defun relint--check-defcustom-type (type name file pos path)
(pcase type
- (`(const . ,rest)
- ;; Skip keywords.
- (while (and rest (symbolp (car rest)))
- (setq rest (cddr rest)))
- (when rest
- (relint--check-re (car rest) name file pos path)))
+ (`(,(or 'const 'string 'regexp) . ,rest)
+ (while (consp rest)
+ (cond ((eq (car rest) :value)
+ (relint--check-re (cadr rest) name file pos path))
+ ((not (cdr rest))
+ (relint--check-re (car rest) name file pos path)))
+ (setq rest (cddr rest))))
(`(,(or 'choice 'radio) . ,choices)
(dolist (choice choices)
(relint--check-defcustom-type choice name file pos path)))))
diff --git a/test/1.elisp b/test/1.elisp
index 865d21a..c00681a 100644
--- a/test/1.elisp
+++ b/test/1.elisp
@@ -75,6 +75,19 @@
:group 'relint-test
:type '(repeat regexp))
+(defcustom bad-custom-8 nil
+ "Doc"
+ :type '(choice (regexp :tag "*" :value "[11]")
+ (string :tag "+" :value "[22]")))
+
+(defcustom bad-custom-9-regexp nil
+ "Doc"
+ :type '(string :tag "+" :value "[33]"))
+
+(defcustom bad-custom-10 nil
+ "regular expression"
+ :type '(string :tag "+" "[44]"))
+
;; Special case.
(defvar compilation-error-regexp-alist-alist
'((aa "a^a" 1 2)
diff --git a/test/1.expected b/test/1.expected
index 8d1e997..4014a72 100644
--- a/test/1.expected
+++ b/test/1.expected
@@ -138,30 +138,42 @@
1.elisp:73:35: In bad-custom-7: Duplicated `a' inside character alternative
(pos 2)
"[aa]"
..^
-1.elisp:80:11: In compilation-error-regexp-alist-alist (aa): Unescaped literal
`^' (pos 1)
+1.elisp:80:9: In bad-custom-8: Duplicated `1' inside character alternative
(pos 2)
+ "[11]"
+ ..^
+1.elisp:80:9: In bad-custom-8: Duplicated `2' inside character alternative
(pos 2)
+ "[22]"
+ ..^
+1.elisp:85:9: In bad-custom-9-regexp: Duplicated `3' inside character
alternative (pos 2)
+ "[33]"
+ ..^
+1.elisp:89:9: In bad-custom-10: Duplicated `4' inside character alternative
(pos 2)
+ "[44]"
+ ..^
+1.elisp:93:11: In compilation-error-regexp-alist-alist (aa): Unescaped literal
`^' (pos 1)
"a^a"
.^
-1.elisp:81:11: In compilation-error-regexp-alist-alist (bb): Unescaped literal
`$' (pos 1)
+1.elisp:94:11: In compilation-error-regexp-alist-alist (bb): Unescaped literal
`$' (pos 1)
"b$b"
.^
-1.elisp:86:8: In define-generic-mode my-mode: Unescaped literal `^' (pos 1)
+1.elisp:99:8: In define-generic-mode my-mode: Unescaped literal `^' (pos 1)
"1^"
.^
-1.elisp:87:8: In define-generic-mode my-mode: Unescaped literal `^' (pos 1)
+1.elisp:100:8: In define-generic-mode my-mode: Unescaped literal `^' (pos 1)
"2^"
.^
-1.elisp:88:12: In define-generic-mode my-mode: Repetition of repetition (pos 2)
+1.elisp:101:12: In define-generic-mode my-mode: Repetition of repetition (pos
2)
"b++"
..^
-1.elisp:94:6: In call to syntax-propertize-rules: Unescaped literal `$' (pos 0)
+1.elisp:107:6: In call to syntax-propertize-rules: Unescaped literal `$' (pos
0)
"$1$"
^
-1.elisp:95:8: In call to syntax-propertize-rules: Unescaped literal `^' (pos 2)
+1.elisp:108:8: In call to syntax-propertize-rules: Unescaped literal `^' (pos
2)
"^2^"
..^
-1.elisp:100:6: In call to syntax-propertize-precompile-rules: Unescaped
literal `$' (pos 0)
+1.elisp:113:6: In call to syntax-propertize-precompile-rules: Unescaped
literal `$' (pos 0)
"$3$"
^
-1.elisp:101:8: In call to syntax-propertize-precompile-rules: Unescaped
literal `^' (pos 2)
+1.elisp:114:8: In call to syntax-propertize-precompile-rules: Unescaped
literal `^' (pos 2)
"^4^"
..^
- [elpa] externals/relint updated (83e677d -> a001a05), Mattias Engdegård, 2020/05/03
- [elpa] externals/relint 96e26a5 02/21: Check keyword arguments :regexp and :regex, Mattias Engdegård, 2020/05/03
- [elpa] externals/relint ba7b747 01/21: Display the number of files found in relint-directory, Mattias Engdegård, 2020/05/03
- [elpa] externals/relint b694c09 07/21: Check split ASCII-raw ranges in rx correctly, Mattias Engdegård, 2020/05/03
- [elpa] externals/relint 12a2b0f 08/21: Use regexp in suppression comments, Mattias Engdegård, 2020/05/03
- [elpa] externals/relint 9259a5c 03/21: Check some :value parameters in defcustom :type clauses,
Mattias Engdegård <=
- [elpa] externals/relint ac75b62 04/21: Check rx-to-string, and the 'regexp' and 'eval' subforms, Mattias Engdegård, 2020/05/03
- [elpa] externals/relint 09ef3df 05/21: Describe the new xr wrapped subsumption warning, Mattias Engdegård, 2020/05/03
- [elpa] externals/relint eb178d5 06/21: Check assignments to imenu-generic-expression, Mattias Engdegård, 2020/05/03
- [elpa] externals/relint 2eba4d7 09/21: Describe new bol/eol/eos warnings, Mattias Engdegård, 2020/05/03
- [elpa] externals/relint cf2a2ae 14/21: Do file-specific checks on arguments to known functions, Mattias Engdegård, 2020/05/03
- [elpa] externals/relint f6d0fed 15/21: Describe the new file-specific warnings, Mattias Engdegård, 2020/05/03
- [elpa] externals/relint 1bf7f25 13/21: Check auto-mode-alist with file-specific checks, Mattias Engdegård, 2020/05/03
- [elpa] externals/relint 4fcc322 16/21: Delay call to file-relative-name until needed, Mattias Engdegård, 2020/05/03
- [elpa] externals/relint 326cfe2 11/21: Check calls to directory-files(-and-attributes), Mattias Engdegård, 2020/05/03
- [elpa] externals/relint 5d3f78d 19/21: Update xr messages ("repetition" changed to "option"), Mattias Engdegård, 2020/05/03