diff mbox series

[bug#43261,2/2] lint: Add '--no-checkers' option.

Message ID 20200907180415.30140-2-zimon.toutoune@gmail.com
State Accepted
Headers show
Series lint: Fix 'no-network' and add 'no-checkers' options | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job

Commit Message

Simon Tournier Sept. 7, 2020, 6:04 p.m. UTC
* guix/scripts/lint.scm (%options, parse-options): Add '--no-checkers' option.
* doc/guix.texi: Document it.
---
 doc/guix.texi         |  5 +++++
 guix/scripts/lint.scm | 39 ++++++++++++++++++++++++---------------
 2 files changed, 29 insertions(+), 15 deletions(-)

Comments

Ludovic Courtès Oct. 28, 2020, 3:18 p.m. UTC | #1
Hi,

zimoun <zimon.toutoune@gmail.com> skribis:

> * guix/scripts/lint.scm (%options, parse-options): Add '--no-checkers' option.
> * doc/guix.texi: Document it.

Please mention the section name (in the manual) and variable names.

> +(define (option-checker short-long)
> +    (option short-long #t #f

Indentation is off.  Also please add a docstring.

> +            (lambda (opt name arg result)
> +              (let ((names (map string->symbol (string-split arg #\,)))
> +                    (checker-names (map lint-checker-name %all-checkers)))
> +                (for-each (lambda (c)
> +                            (unless (memq c checker-names)
> +                              (leave (G_ "~a: invalid checker~%") c)))
> +                          names)
> +                (alist-cons (string->symbol (cadr short-long))

Use ‘match’ instead of ‘cadr’, or maybe make it a parameter of this
procedure?

Thanks!

Ludo’.
Simon Tournier Oct. 28, 2020, 4:58 p.m. UTC | #2
Hi,

Thank you for the review.  All the comments are included in v2.


On Wed, 28 Oct 2020 at 16:18, Ludovic Courtès <ludo@gnu.org> wrote:

> Use ‘match’ instead of ‘cadr’, or maybe make it a parameter of this
> procedure?

Well, it is a matter of taste. :-)  Just to be sure, that’s the point:

--8<---------------cut here---------------start------------->8---
scheme@(guile-user)> ,use(ice-9 match)
scheme@(guile-user)> (define foo '(hello world))
scheme@(guile-user)> (cadr foo)
$2 = world
scheme@(guile-user)> (match foo ((hi all) all))
$3 = world
--8<---------------cut here---------------end--------------->8---

right?


Cheers,
simon
diff mbox series

Patch

diff --git a/doc/guix.texi b/doc/guix.texi
index ea2aa1581e..bcc6fe8324 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -10632,6 +10632,11 @@  and exit.
 Only enable the checkers specified in a comma-separated list using the
 names returned by @option{--list-checkers}.
 
+@item --no-checkers
+@itemx -x
+Only disable the checkers specified in a comma-separated list using the
+names returned by @option{--list-checkers}.
+
 @item --no-network
 @itemx -n
 Only enable the checkers which do not dependent on Internet access.
diff --git a/guix/scripts/lint.scm b/guix/scripts/lint.scm
index c56576fcbd..0007e18bcd 100644
--- a/guix/scripts/lint.scm
+++ b/guix/scripts/lint.scm
@@ -99,6 +99,9 @@  run the checkers on all packages.\n"))
   -c, --checkers=CHECKER1,CHECKER2...
                          only run the specified checkers"))
   (display (G_ "
+  -x, --no-checkers=CHECKER1,CHECKER2...
+                         exclude the specified checkers"))
+  (display (G_ "
   -n, --no-network       only run checkers which do not access to network"))
 
   (display (G_ "
@@ -113,26 +116,29 @@  run the checkers on all packages.\n"))
   (newline)
   (show-bug-report-information))
 
+(define (option-checker short-long)
+    (option short-long #t #f
+            (lambda (opt name arg result)
+              (let ((names (map string->symbol (string-split arg #\,)))
+                    (checker-names (map lint-checker-name %all-checkers)))
+                (for-each (lambda (c)
+                            (unless (memq c checker-names)
+                              (leave (G_ "~a: invalid checker~%") c)))
+                          names)
+                (alist-cons (string->symbol (cadr short-long))
+                            (filter (lambda (checker)
+                                      (member (lint-checker-name checker)
+                                              names))
+                                    %all-checkers)
+                            result)))))
 
 (define %options
   ;; Specification of the command-line options.
   ;; TODO: add some options:
   ;; * --certainty=[low,medium,high]: only run checkers that have at least this
   ;;                                  'certainty'.
-  (list (option '(#\c "checkers") #t #f
-                (lambda (opt name arg result)
-                  (let ((names (map string->symbol (string-split arg #\,)))
-                        (checker-names (map lint-checker-name %all-checkers)))
-                    (for-each (lambda (c)
-                                (unless (memq c checker-names)
-                                  (leave (G_ "~a: invalid checker~%") c)))
-                              names)
-                    (alist-cons 'checkers
-                                (filter (lambda (checker)
-                                          (member (lint-checker-name checker)
-                                                  names))
-                                        %all-checkers)
-                                result))))
+  (list (option-checker '(#\c "checkers"))
+        (option-checker '(#\x "no-checkers"))
         (option '(#\n "no-network") #f #f
                 (lambda (opt name arg result)
                   (alist-cons 'no-network? #t result)))
@@ -169,7 +175,10 @@  run the checkers on all packages.\n"))
                               value)
                              (_ #f))
                            (reverse opts)))
-         (the-checkers (or (assoc-ref opts 'checkers) %all-checkers))
+         (no-checkers (or (assoc-ref opts 'no-checkers) '()))
+         (the-checkers (filter (lambda (checker)
+                                 (not (member checker no-checkers)))
+                               (or (assoc-ref opts 'checkers) %all-checkers)))
          (checkers
           (if (assoc-ref opts 'no-network?)
               (filter (lambda (checker)