[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/relint a1ea26c 01/16: Check regexp arguments to more fu
From: |
Mattias Engdegård |
Subject: |
[elpa] externals/relint a1ea26c 01/16: Check regexp arguments to more functions |
Date: |
Mon, 30 Nov 2020 05:00:56 -0500 (EST) |
branch: externals/relint
commit a1ea26c4f7d8e6618834f04bb634f8ab1f36cb1a
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>
Check regexp arguments to more functions
sort-regexp-fields
delete-matching-lines (alias for keep-lines)
delete-non-matching-lines (alias for flush-lines)
count-matches (alias for how-many)
---
relint.el | 9 ++++++++-
test/2.elisp | 9 ++++++++-
test/2.expected | 55 +++++++++++++++++++++++++++++++++++--------------------
3 files changed, 51 insertions(+), 22 deletions(-)
diff --git a/relint.el b/relint.el
index b95ef5c..3b40d12 100644
--- a/relint.el
+++ b/relint.el
@@ -1860,7 +1860,8 @@ directly."
'posix-string-match
'search-forward-regexp 'search-backward-regexp
'kill-matching-buffers
- 'keep-lines 'flush-lines 'how-many)
+ 'keep-lines 'flush-lines 'how-many
+ 'delete-matching-lines 'delete-non-matching-lines
'count-matches)
,re-arg . ,_)
(unless (and (symbolp re-arg)
(memq re-arg relint--checked-variables))
@@ -1899,6 +1900,12 @@ directly."
,_ ,_ ,re-arg . ,_)
(relint--check-file-name-re re-arg (format "call to %s" (car form))
pos (cons 3 path)))
+ (`(sort-regexp-fields ,_ ,record-arg ,key-arg . ,_)
+ (let ((name (format "call to %s" (car form))))
+ (relint--check-re record-arg name pos (cons 2 path))
+ (let ((key-re (relint--eval-or-nil key-arg)))
+ (when (and (stringp key-re) (not (equal key-re "\\&")))
+ (relint--check-re key-re name pos (cons 3 path))))))
(`(,(or 'skip-chars-forward 'skip-chars-backward)
,skip-arg . ,_)
(let ((str (relint--get-string skip-arg)))
diff --git a/test/2.elisp b/test/2.elisp
index f069a33..36d338a 100644
--- a/test/2.elisp
+++ b/test/2.elisp
@@ -29,7 +29,10 @@
(string-trim s "[yy]" "[zz]")
(directory-files s nil "+1")
(directory-files-and-attributes s nil "+2")
- (directory-files-recursively s "+3"))
+ (directory-files-recursively s "+3")
+ (delete-matching-lines "+4")
+ (delete-non-matching-lines "+5")
+ (count-matches "+6"))
;; Test argument names as means of detecting regexps.
(defun f2 (x1 my-regexp x2 my-regex x3 my-re x4 my-pattern x5 re)
@@ -57,3 +60,7 @@
(defun f7 ()
(alpha beta :regexp "[11]")
(gamma :regex "[22]" delta))
+
+(defun f8 ()
+ (sort-regexp-fields nil "^.*$x" "\\&" (point-min) (point-max))
+ (sort-regexp-fields nil "^.*$" "\\%" (point-min) (point-max)))
diff --git a/test/2.expected b/test/2.expected
index 347f31d..aa58eca 100644
--- a/test/2.expected
+++ b/test/2.expected
@@ -88,63 +88,78 @@
2.elisp:32:35: In call to directory-files-recursively: Unescaped literal `+'
(pos 0)
"+3"
^
-2.elisp:45:17: In call to f2: Duplicated `B' inside character alternative (pos
2)
+2.elisp:33:27: In call to delete-matching-lines: Unescaped literal `+' (pos 0)
+ "+4"
+ ^
+2.elisp:34:31: In call to delete-non-matching-lines: Unescaped literal `+'
(pos 0)
+ "+5"
+ ^
+2.elisp:35:19: In call to count-matches: Unescaped literal `+' (pos 0)
+ "+6"
+ ^
+2.elisp:48:17: In call to f2: Duplicated `B' inside character alternative (pos
2)
"[BB]"
..^
-2.elisp:45:31: In call to f2: Duplicated `D' inside character alternative (pos
2)
+2.elisp:48:31: In call to f2: Duplicated `D' inside character alternative (pos
2)
"[DD]"
..^
-2.elisp:45:45: In call to f2: Duplicated `F' inside character alternative (pos
2)
+2.elisp:48:45: In call to f2: Duplicated `F' inside character alternative (pos
2)
"[FF]"
..^
-2.elisp:45:59: In call to f2: Duplicated `H' inside character alternative (pos
2)
+2.elisp:48:59: In call to f2: Duplicated `H' inside character alternative (pos
2)
"[HH]"
..^
-2.elisp:45:73: In call to f2: Duplicated `J' inside character alternative (pos
2)
+2.elisp:48:73: In call to f2: Duplicated `J' inside character alternative (pos
2)
"[JJ]"
..^
-2.elisp:46:17: In call to s2: Duplicated `B' inside character alternative (pos
2)
+2.elisp:49:17: In call to s2: Duplicated `B' inside character alternative (pos
2)
"[BB]"
..^
-2.elisp:46:31: In call to s2: Duplicated `D' inside character alternative (pos
2)
+2.elisp:49:31: In call to s2: Duplicated `D' inside character alternative (pos
2)
"[DD]"
..^
-2.elisp:46:45: In call to s2: Duplicated `F' inside character alternative (pos
2)
+2.elisp:49:45: In call to s2: Duplicated `F' inside character alternative (pos
2)
"[FF]"
..^
-2.elisp:46:59: In call to s2: Duplicated `H' inside character alternative (pos
2)
+2.elisp:49:59: In call to s2: Duplicated `H' inside character alternative (pos
2)
"[HH]"
..^
-2.elisp:46:73: In call to s2: Duplicated `J' inside character alternative (pos
2)
+2.elisp:49:73: In call to s2: Duplicated `J' inside character alternative (pos
2)
"[JJ]"
..^
-2.elisp:47:17: In call to m2: Duplicated `B' inside character alternative (pos
2)
+2.elisp:50:17: In call to m2: Duplicated `B' inside character alternative (pos
2)
"[BB]"
..^
-2.elisp:47:31: In call to m2: Duplicated `D' inside character alternative (pos
2)
+2.elisp:50:31: In call to m2: Duplicated `D' inside character alternative (pos
2)
"[DD]"
..^
-2.elisp:47:45: In call to m2: Duplicated `F' inside character alternative (pos
2)
+2.elisp:50:45: In call to m2: Duplicated `F' inside character alternative (pos
2)
"[FF]"
..^
-2.elisp:47:59: In call to m2: Duplicated `H' inside character alternative (pos
2)
+2.elisp:50:59: In call to m2: Duplicated `H' inside character alternative (pos
2)
"[HH]"
..^
-2.elisp:47:73: In call to m2: Duplicated `J' inside character alternative (pos
2)
+2.elisp:50:73: In call to m2: Duplicated `J' inside character alternative (pos
2)
"[JJ]"
..^
-2.elisp:55:17: In call to f5: Duplicated `b' inside character alternative (pos
2)
+2.elisp:58:17: In call to f5: Duplicated `b' inside character alternative (pos
2)
"[bb]"
..^
-2.elisp:55:24: In call to f5: Duplicated `c' inside character alternative (pos
2)
+2.elisp:58:24: In call to f5: Duplicated `c' inside character alternative (pos
2)
"[cc]"
..^
-2.elisp:55:31: In call to f5: Duplicated `d' inside character alternative (pos
2)
+2.elisp:58:31: In call to f5: Duplicated `d' inside character alternative (pos
2)
"[dd]"
..^
-2.elisp:58:26: In :regexp parameter: Duplicated `1' inside character
alternative (pos 2)
+2.elisp:61:26: In :regexp parameter: Duplicated `1' inside character
alternative (pos 2)
"[11]"
..^
-2.elisp:59:20: In :regex parameter: Duplicated `2' inside character
alternative (pos 2)
+2.elisp:62:20: In :regex parameter: Duplicated `2' inside character
alternative (pos 2)
"[22]"
..^
+2.elisp:65:31: In call to sort-regexp-fields: Unescaped literal `$' (pos 3)
+ "^.*$x"
+ ...^
+2.elisp:66:35: In call to sort-regexp-fields: Escaped non-special character
`%' (pos 0)
+ "\\%"
+ ^
- [elpa] externals/relint updated (0c35e02 -> 26639c5), Mattias Engdegård, 2020/11/30
- [elpa] externals/relint a1ea26c 01/16: Check regexp arguments to more functions,
Mattias Engdegård <=
- [elpa] externals/relint d0fa8a8 10/16: Fix false positives in regexp provenance checks, Mattias Engdegård, 2020/11/30
- [elpa] externals/relint 29e5427 11/16: Recognise a few more `featurep` arguments, Mattias Engdegård, 2020/11/30
- [elpa] externals/relint 26639c5 16/16: Require xr 1.20, Mattias Engdegård, 2020/11/30
- [elpa] externals/relint 7690e3a 08/16: Scan font-lock-defaults correctly, Mattias Engdegård, 2020/11/30
- [elpa] externals/relint 4b78e14 09/16: Add table of contents to README, and some advice, Mattias Engdegård, 2020/11/30
- [elpa] externals/relint c792bde 15/16: Perform Emacs version check at compile time, Mattias Engdegård, 2020/11/30
- [elpa] externals/relint c8fd922 12/16: Minor looking-at optimisation, Mattias Engdegård, 2020/11/30
- [elpa] externals/relint 5720e12 07/16: Scan regexp arguments to functions in s.el, Mattias Engdegård, 2020/11/30
- [elpa] externals/relint f0241bc 13/16: Increment version to 1.19, Mattias Engdegård, 2020/11/30
- [elpa] externals/relint 9173a91 05/16: Add progress indicator for interactive relint-directory, Mattias Engdegård, 2020/11/30