emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/relint bbbe451 1/5: Don't search for regexps into condi


From: Mattias Engdegård
Subject: [elpa] externals/relint bbbe451 1/5: Don't search for regexps into conditions
Date: Thu, 23 Jan 2020 05:14:19 -0500 (EST)

branch: externals/relint
commit bbbe451ca9587eba97548f738747487934a457b4
Author: Mattias Engdegård <address@hidden>
Commit: Mattias Engdegård <address@hidden>

    Don't search for regexps into conditions
    
    The filter is currently only limited to 'if', 'when', 'unless' and
    'while', but it avoids some false positives such as
    
      (skip-chars-forward (if C ...))
    
    when C contains regexp-looking things.
    Future work: add 'cond' as well.
---
 relint.el    | 5 ++++-
 test/6.elisp | 7 +++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/relint.el b/relint.el
index 0c97f05..ba404f8 100644
--- a/relint.el
+++ b/relint.el
@@ -1073,11 +1073,14 @@ EXPANDED is a list of expanded functions, to prevent 
recursion."
     nil)
    ((null (cdr (last expr)))
     (let* ((head (car expr))
+           (args (if (memq head '(if when unless while))
+                     (cddr expr)
+                   (cdr expr)))
            (alias (assq head relint--alias-defs)))
       (if alias
           (relint--regexp-generators (cons (cdr alias) (cdr expr)) expanded)
         (append (mapcan (lambda (x) (relint--regexp-generators x expanded))
-                        (cdr expr))
+                        args)
                 (let ((fun (assq head relint--function-defs)))
                   (and fun (not (memq head expanded))
                        (mapcan (lambda (x)
diff --git a/test/6.elisp b/test/6.elisp
index e88e7c8..e82b6b4 100644
--- a/test/6.elisp
+++ b/test/6.elisp
@@ -39,6 +39,13 @@
   (skip-syntax-backward (rx "w-"))
   (skip-syntax-forward (rx-to-string z)))
 
+;; Test incorrect provenance tracing
+(defun test-regexp-in-condition (x y z)
+  (format "[%s]" (if (regexp-quote x) y z))
+  (skip-chars-forward (when some-regexp y))
+  (skip-syntax-backward (unless (myrefun x) y))
+  (skip-chars-backward (while (myrefun x) z)))
+
 ;; Test suppression
 (defun test-suppression ()
   ;; relint suppression: Unescaped literal `$'



reply via email to

[Prev in Thread] Current Thread [Next in Thread]