branch: externals/relint
commit 326cfe24cd110e4cf7686b4a154c7bdb55a727e8
Author: Mattias Engdegård <matti...@acm.org>
Commit: Mattias Engdegård <matti...@acm.org>

    Check calls to directory-files(-and-attributes)
---
 relint.el       |  4 ++++
 test/2.elisp    |  5 ++++-
 test/2.expected | 49 +++++++++++++++++++++++++++++--------------------
 3 files changed, 37 insertions(+), 21 deletions(-)

diff --git a/relint.el b/relint.el
index b17d451..6c81221 100644
--- a/relint.el
+++ b/relint.el
@@ -1844,6 +1844,10 @@ directly."
                          (memq trim relint--checked-variables))
               (relint--check-re trim (format "call to %s" (car form))
                                 file pos (cons 4 path))))))
+       (`(,(or 'directory-files 'directory-files-and-attributes)
+          ,_ ,_ ,re-arg . ,_)
+        (relint--check-re re-arg (format "call to %s" (car form))
+                          file 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 a96cef0..f069a33 100644
--- a/test/2.elisp
+++ b/test/2.elisp
@@ -26,7 +26,10 @@
   (split-string-and-unquote s "[vv]")
   (string-trim-left s "[ww]")
   (string-trim-right s "[xx]")
-  (string-trim s "[yy]" "[zz]"))
+  (string-trim s "[yy]" "[zz]")
+  (directory-files s nil "+1")
+  (directory-files-and-attributes s nil "+2")
+  (directory-files-recursively s "+3"))
 
 ;; Test argument names as means of detecting regexps.
 (defun f2 (x1 my-regexp x2 my-regex x3 my-re x4 my-pattern x5 re)
diff --git a/test/2.expected b/test/2.expected
index 0dbcfc8..347f31d 100644
--- a/test/2.expected
+++ b/test/2.expected
@@ -79,63 +79,72 @@
 2.elisp:29:28: In call to string-trim: Duplicated `z' inside character 
alternative (pos 2)
   "[zz]"
    ..^
-2.elisp:42:17: In call to f2: Duplicated `B' inside character alternative (pos 
2)
+2.elisp:30:27: In call to directory-files: Unescaped literal `+' (pos 0)
+  "+1"
+   ^
+2.elisp:31:42: In call to directory-files-and-attributes: Unescaped literal 
`+' (pos 0)
+  "+2"
+   ^
+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)
   "[BB]"
    ..^
-2.elisp:42:31: In call to f2: Duplicated `D' inside character alternative (pos 
2)
+2.elisp:45:31: In call to f2: Duplicated `D' inside character alternative (pos 
2)
   "[DD]"
    ..^
-2.elisp:42:45: In call to f2: Duplicated `F' inside character alternative (pos 
2)
+2.elisp:45:45: In call to f2: Duplicated `F' inside character alternative (pos 
2)
   "[FF]"
    ..^
-2.elisp:42:59: In call to f2: Duplicated `H' inside character alternative (pos 
2)
+2.elisp:45:59: In call to f2: Duplicated `H' inside character alternative (pos 
2)
   "[HH]"
    ..^
-2.elisp:42:73: In call to f2: Duplicated `J' inside character alternative (pos 
2)
+2.elisp:45:73: In call to f2: Duplicated `J' inside character alternative (pos 
2)
   "[JJ]"
    ..^
-2.elisp:43:17: In call to s2: Duplicated `B' inside character alternative (pos 
2)
+2.elisp:46:17: In call to s2: Duplicated `B' inside character alternative (pos 
2)
   "[BB]"
    ..^
-2.elisp:43:31: In call to s2: Duplicated `D' inside character alternative (pos 
2)
+2.elisp:46:31: In call to s2: Duplicated `D' inside character alternative (pos 
2)
   "[DD]"
    ..^
-2.elisp:43:45: In call to s2: Duplicated `F' inside character alternative (pos 
2)
+2.elisp:46:45: In call to s2: Duplicated `F' inside character alternative (pos 
2)
   "[FF]"
    ..^
-2.elisp:43:59: In call to s2: Duplicated `H' inside character alternative (pos 
2)
+2.elisp:46:59: In call to s2: Duplicated `H' inside character alternative (pos 
2)
   "[HH]"
    ..^
-2.elisp:43:73: In call to s2: Duplicated `J' inside character alternative (pos 
2)
+2.elisp:46:73: In call to s2: Duplicated `J' inside character alternative (pos 
2)
   "[JJ]"
    ..^
-2.elisp:44:17: In call to m2: Duplicated `B' inside character alternative (pos 
2)
+2.elisp:47:17: In call to m2: Duplicated `B' inside character alternative (pos 
2)
   "[BB]"
    ..^
-2.elisp:44:31: In call to m2: Duplicated `D' inside character alternative (pos 
2)
+2.elisp:47:31: In call to m2: Duplicated `D' inside character alternative (pos 
2)
   "[DD]"
    ..^
-2.elisp:44:45: In call to m2: Duplicated `F' inside character alternative (pos 
2)
+2.elisp:47:45: In call to m2: Duplicated `F' inside character alternative (pos 
2)
   "[FF]"
    ..^
-2.elisp:44:59: In call to m2: Duplicated `H' inside character alternative (pos 
2)
+2.elisp:47:59: In call to m2: Duplicated `H' inside character alternative (pos 
2)
   "[HH]"
    ..^
-2.elisp:44:73: In call to m2: Duplicated `J' inside character alternative (pos 
2)
+2.elisp:47:73: In call to m2: Duplicated `J' inside character alternative (pos 
2)
   "[JJ]"
    ..^
-2.elisp:52:17: In call to f5: Duplicated `b' inside character alternative (pos 
2)
+2.elisp:55:17: In call to f5: Duplicated `b' inside character alternative (pos 
2)
   "[bb]"
    ..^
-2.elisp:52:24: In call to f5: Duplicated `c' inside character alternative (pos 
2)
+2.elisp:55:24: In call to f5: Duplicated `c' inside character alternative (pos 
2)
   "[cc]"
    ..^
-2.elisp:52:31: In call to f5: Duplicated `d' inside character alternative (pos 
2)
+2.elisp:55:31: In call to f5: Duplicated `d' inside character alternative (pos 
2)
   "[dd]"
    ..^
-2.elisp:55:26: In :regexp parameter: Duplicated `1' inside character 
alternative (pos 2)
+2.elisp:58:26: In :regexp parameter: Duplicated `1' inside character 
alternative (pos 2)
   "[11]"
    ..^
-2.elisp:56:20: In :regex parameter: Duplicated `2' inside character 
alternative (pos 2)
+2.elisp:59:20: In :regex parameter: Duplicated `2' inside character 
alternative (pos 2)
   "[22]"
    ..^

Reply via email to