[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/relint cf2a2ae 14/21: Do file-specific checks on argume
From: |
Mattias Engdegård |
Subject: |
[elpa] externals/relint cf2a2ae 14/21: Do file-specific checks on arguments to known functions |
Date: |
Sun, 3 May 2020 11:13:37 -0400 (EDT) |
branch: externals/relint
commit cf2a2ae075f132aab97a32fc4d0c8921068217bb
Author: Mattias Engdegård <address@hidden>
Commit: Mattias Engdegård <address@hidden>
Do file-specific checks on arguments to known functions
This includes directory-files, directory-files-and-attributes,
directory-files-recursively, load-history-filename-element,
and modify-coding-system-alist (with type = file).
---
relint.el | 20 +++++++++++++++-----
test/12.elisp | 9 +++++++++
test/12.expected | 15 +++++++++++++++
3 files changed, 39 insertions(+), 5 deletions(-)
diff --git a/relint.el b/relint.el
index 03a9421..1adcaee 100644
--- a/relint.el
+++ b/relint.el
@@ -1887,7 +1887,6 @@ directly."
'posix-looking-at 'posix-search-backward 'posix-search-forward
'posix-string-match
'search-forward-regexp 'search-backward-regexp
- 'load-history-filename-element
'kill-matching-buffers
'keep-lines 'flush-lines 'how-many)
,re-arg . ,_)
@@ -1895,9 +1894,14 @@ directly."
(memq re-arg relint--checked-variables))
(relint--check-re re-arg (format "call to %s" (car form))
file pos (cons 1 path))))
+ (`(load-history-filename-element ,re-arg)
+ (relint--check-file-name-re re-arg (format "call to %s" (car form))
+ file pos (cons 1 path)))
+ (`(directory-files-recursively ,_ ,re-arg . ,_)
+ (relint--check-file-name-re re-arg (format "call to %s" (car form))
+ file pos (cons 2 path)))
(`(,(or 'split-string 'split-string-and-unquote
- 'string-trim-left 'string-trim-right 'string-trim
- 'directory-files-recursively)
+ 'string-trim-left 'string-trim-right 'string-trim)
,_ ,re-arg . ,rest)
(unless (and (symbolp re-arg)
(memq re-arg relint--checked-variables))
@@ -1921,8 +1925,8 @@ directly."
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)))
+ (relint--check-file-name-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)))
@@ -2078,6 +2082,12 @@ directly."
(`(add-to-list 'auto-mode-alist ,elem . ,_)
(relint--check-auto-mode-alist-expr
elem (car form) file pos (cons 2 path)))
+ (`(modify-coding-system-alist ,type ,re-arg ,_)
+ (funcall
+ (if (eq (relint--eval-or-nil type) 'file)
+ #'relint--check-file-name-re
+ #'relint--check-re)
+ re-arg (format "call to %s" (car form)) file pos (cons 2 path)))
(`(,name . ,args)
(let ((alias (assq name relint--alias-defs)))
(when alias
diff --git a/test/12.elisp b/test/12.elisp
index ea04551..04ea09c 100644
--- a/test/12.elisp
+++ b/test/12.elisp
@@ -14,3 +14,12 @@
(setq auto-mode-alist (append '((".hh\\'" . some-mode)
(".ii\\'" . some-mode))
auto-mode-alist))
+
+;; File-matching regexp functions
+
+(defun f12 (d)
+ (directory-files d nil ".txt\\'")
+ (directory-files-and-attributes d nil "\\.pas$")
+ (directory-files-recursively d "^abc")
+ (modify-coding-system-alist 'file "\\.ml$" 'utf-8)
+ (modify-coding-system-alist 'process "+xx$" 'utf-8))
diff --git a/test/12.expected b/test/12.expected
index 6abea93..ecef078 100644
--- a/test/12.expected
+++ b/test/12.expected
@@ -22,3 +22,18 @@
12.elisp:15:35: Possibly unescaped `.' in file-matching regexp (pos 0)
".ii\\'"
^
+12.elisp:21:27: Possibly unescaped `.' in file-matching regexp (pos 0)
+ ".txt\\'"
+ ^
+12.elisp:22:48: Use \' instead of $ in file-matching regexp (pos 5)
+ "\\.pas$"
+ ......^
+12.elisp:23:35: Use \` instead of ^ in file-matching regexp (pos 0)
+ "^abc"
+ ^
+12.elisp:24:43: 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)
+ "+xx$"
+ ^
- [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, 2020/05/03
- [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 <=
- [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, 2020/05/03