[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/relint 8f49686 18/21: Move file-specific checks to xr
From: |
Mattias Engdegård |
Subject: |
[elpa] externals/relint 8f49686 18/21: Move file-specific checks to xr |
Date: |
Sun, 3 May 2020 11:13:39 -0400 (EDT) |
branch: externals/relint
commit 8f49686f268dc10e1074f1c344084e3f2bafc7ee
Author: Mattias Engdegård <address@hidden>
Commit: Mattias Engdegård <address@hidden>
Move file-specific checks to xr
---
relint.el | 48 ++++++------------------------------------------
test/12.expected | 24 ++++++++++++------------
2 files changed, 18 insertions(+), 54 deletions(-)
diff --git a/relint.el b/relint.el
index ba10355..b775b8a 100644
--- a/relint.el
+++ b/relint.el
@@ -320,6 +320,9 @@ or nil if no position could be determined."
(defun relint--check-re-string (re name file pos path)
(relint--check-string re #'xr-lint name file pos path))
+(defun relint--check-file-re-string (re name file pos path)
+ (relint--check-string re (lambda (x) (xr-lint x 'file)) name file pos path))
+
(defun relint--check-syntax-string (syntax name file pos path)
(relint--check-string syntax #'relint--syntax-string-lint name file pos
path))
@@ -1176,59 +1179,20 @@ or in the car of an element."
file pos (if literal (cons 1 elem-path) elem-path))))
form path))
-(defun relint--extra-file-name-re-checks (string file pos path)
- "Perform extra checks on STRING assuming it matches file names."
-
- ;; It would be much easier to do these checks (and more) on the rx
- ;; representation, but unfortunately xr doesn't return a
- ;; location-annotated expression right now.
- (let ((len (length string))
- (start 0))
- (while (and (< start len)
- ;; Skip anything that is NOT one of . ^ $
- (string-match (rx (* (or (not (any "\\.$^["))
- (seq "\\" anything)
- (seq "[" (opt "^") (opt "]")
- (* (not (any "]")))
- "]"))))
- string start))
- (setq start (match-end 0))
- (let* ((m (string-match (rx (or "^" "$" (seq "." (opt (any "*+?")))))
- string start))
- (end (match-end 0)))
- (when (and m (= m start))
- (pcase (match-string 0 string)
- ("^" (relint--warn
- file pos path
- "Use \\` instead of ^ in file-matching regexp"
- string start))
- ("$" (relint--warn
- file pos path
- "Use \\' instead of $ in file-matching regexp"
- string start))
- ;; We assume that .* etc are intended.
- ("." (relint--warn
- file pos path
- (format-message
- "Possibly unescaped `.' in file-matching regexp")
- string start)))
- (setq start end))))))
-
(defun relint--check-file-name-re (form name file pos path)
(let ((re (relint--get-string form)))
(when re
- (relint--check-re re name file pos path)
- (relint--extra-file-name-re-checks re file pos path))))
+ (relint--check-file-re-string re name file pos path))))
(defun relint--check-auto-mode-alist-expr (form name file pos path)
"Check a single element added to `auto-mode-alist'."
(pcase form
(`(quote (,(and (pred stringp) str) . ,_))
- (relint--check-file-name-re str name file pos (cons 0 (cons 1 path))))
+ (relint--check-file-re-string str name file pos (cons 0 (cons 1 path))))
(_
(let ((val (relint--eval-or-nil form)))
(when (and (consp val) (stringp (car val)))
- (relint--check-file-name-re (car val) name file pos path))))))
+ (relint--check-file-re-string (car val) name file pos path))))))
(defun relint--check-auto-mode-alist (form name file pos path)
(relint--eval-list-iter
diff --git a/test/12.expected b/test/12.expected
index ecef078..e0ab05b 100644
--- a/test/12.expected
+++ b/test/12.expected
@@ -1,37 +1,37 @@
-12.elisp:9:6: Possibly unescaped `.' in file-matching regexp (pos 0)
+12.elisp:9:6: In define-generic-mode my-mode: Possibly unescaped `.' in
file-matching regexp (pos 0)
".aa\\'"
^
-12.elisp:9:20: Use \' instead of $ in file-matching regexp (pos 4)
+12.elisp:9:20: In define-generic-mode my-mode: Use \' instead of $ in
file-matching regexp (pos 4)
"\\.bb$"
.....^
-12.elisp:9:24: Use \` instead of ^ in file-matching regexp (pos 0)
+12.elisp:9:24: In define-generic-mode my-mode: Use \` instead of ^ in
file-matching regexp (pos 0)
"^cc.*dd"
^
-12.elisp:11:39: Use \' instead of $ in file-matching regexp (pos 4)
+12.elisp:11:39: In add-to-list: Use \' instead of $ in file-matching regexp
(pos 4)
"\\.ee$"
.....^
-12.elisp:12:10: Possibly unescaped `.' in file-matching regexp (pos 0)
+12.elisp:12:10: In auto-mode-alist: Possibly unescaped `.' in file-matching
regexp (pos 0)
".ff\\'"
^
-12.elisp:13:32: Possibly unescaped `.' in file-matching regexp (pos 0)
+12.elisp:13:32: In auto-mode-alist: Possibly unescaped `.' in file-matching
regexp (pos 0)
".gg\\'"
^
-12.elisp:14:35: Possibly unescaped `.' in file-matching regexp (pos 0)
+12.elisp:14:35: In auto-mode-alist: Possibly unescaped `.' in file-matching
regexp (pos 0)
".hh\\'"
^
-12.elisp:15:35: Possibly unescaped `.' in file-matching regexp (pos 0)
+12.elisp:15:35: In auto-mode-alist: Possibly unescaped `.' in file-matching
regexp (pos 0)
".ii\\'"
^
-12.elisp:21:27: Possibly unescaped `.' in file-matching regexp (pos 0)
+12.elisp:21:27: In call to directory-files: Possibly unescaped `.' in
file-matching regexp (pos 0)
".txt\\'"
^
-12.elisp:22:48: Use \' instead of $ in file-matching regexp (pos 5)
+12.elisp:22:48: In call to directory-files-and-attributes: Use \' instead of $
in file-matching regexp (pos 5)
"\\.pas$"
......^
-12.elisp:23:35: Use \` instead of ^ in file-matching regexp (pos 0)
+12.elisp:23:35: In call to directory-files-recursively: Use \` instead of ^ in
file-matching regexp (pos 0)
"^abc"
^
-12.elisp:24:43: Use \' instead of $ in file-matching regexp (pos 4)
+12.elisp:24:43: In call to modify-coding-system-alist: Use \' instead of $ in
file-matching regexp (pos 4)
"\\.ml$"
.....^
12.elisp:25:41: In call to modify-coding-system-alist: Unescaped literal `+'
(pos 0)
- [elpa] externals/relint cf2a2ae 14/21: Do file-specific checks on arguments to known functions, (continued)
- [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
- [elpa] externals/relint a50ed0b 20/21: Don't escape printable chars in rx warnings, Mattias Engdegård, 2020/05/03
- [elpa] externals/relint cdd65ae 10/21: Add section about how relint works, Mattias Engdegård, 2020/05/03
- [elpa] externals/relint 636e172 12/21: Add filename-specific checks (unused so far), Mattias Engdegård, 2020/05/03
- [elpa] externals/relint 008fad0 17/21: Repair relint-current-buffer after thunking file parameter, Mattias Engdegård, 2020/05/03
- [elpa] externals/relint 8f49686 18/21: Move file-specific checks to xr,
Mattias Engdegård <=
- [elpa] externals/relint a001a05 21/21: Increment version to 1.16, Mattias Engdegård, 2020/05/03