unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: zimoun <zimon.toutoune@gmail.com>
To: 43261@debbugs.gnu.org
Cc: ludo@gnu.org, zimoun <zimon.toutoune@gmail.com>
Subject: [bug#43261] [PATCH v2 2/2] scripts: lint: Add '--exclude' option.
Date: Wed, 28 Oct 2020 17:51:12 +0100	[thread overview]
Message-ID: <20201028165112.28575-2-zimon.toutoune@gmail.com> (raw)
In-Reply-To: <20201028165112.28575-1-zimon.toutoune@gmail.com>

* guix/scripts/lint.scm (%options, parse-options): Add '--exclude' option.
(option-checker): New helper function.
* doc/guix.texi (Invoking guix lint): Document it.
---
 doc/guix.texi         |  5 +++++
 guix/scripts/lint.scm | 44 ++++++++++++++++++++++++++++---------------
 2 files changed, 34 insertions(+), 15 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 19cf26572c..1c146026fd 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -11528,6 +11528,11 @@ and exit.
 Only enable the checkers specified in a comma-separated list using the
 names returned by @option{--list-checkers}.
 
+@item --exclude
+@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 1ab563a3fa..cfe1a41211 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, --exclude=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,34 @@ run the checkers on all packages.\n"))
   (newline)
   (show-bug-report-information))
 
+(define (option-checker short-long)
+  ;; Factorize the creation of the two options -c/--checkers and -x/--exclude,
+  ;; see %options.  The parameter SHORT-LONG is the list containing the short
+  ;; and long name.  The alist uses the long name as symbol.
+  (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))
+                  (option-name (string->symbol (match short-long
+                                                 ((short long) long)))))
+              (for-each (lambda (c)
+                          (unless (memq c checker-names)
+                            (leave (G_ "~a: invalid checker~%") c)))
+                        names)
+              (alist-cons option-name
+                          (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 "exclude"))
         (option '(#\n "no-network") #f #f
                 (lambda (opt name arg result)
                   (alist-cons 'no-network? #t result)))
@@ -172,7 +183,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 'exclude) '()))
+         (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)
-- 
2.28.0





  reply	other threads:[~2020-10-28 17:09 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-07 18:02 [bug#43261] [PATCH 0/2] lint: Fix 'no-network' and add 'no-checkers' options zimoun
2020-09-07 18:04 ` [bug#43261] [PATCH 1/2] lint: Fix '--no-network' option zimoun
2020-09-07 18:04   ` [bug#43261] [PATCH 2/2] lint: Add '--no-checkers' option zimoun
2020-10-28 15:18     ` Ludovic Courtès
2020-10-28 16:58       ` zimoun
2020-09-08  7:56 ` [bug#43261] [PATCH 0/2] lint: Fix 'no-network' and add 'no-checkers' options Efraim Flashner
2020-09-08  9:16   ` zimoun
2020-10-28 15:13   ` Ludovic Courtès
2020-10-09 20:39 ` zimoun
2020-10-28 16:51 ` [bug#43261] [PATCH v2 1/2] scripts: lint: Fix '--no-network' option zimoun
2020-10-28 16:51   ` zimoun [this message]
2020-10-29 23:28     ` bug#43261: [PATCH v2 2/2] scripts: lint: Add '--exclude' option Ludovic Courtès
2020-10-29 23:25   ` [bug#43261] [PATCH v2 1/2] scripts: lint: Fix '--no-network' option Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201028165112.28575-2-zimon.toutoune@gmail.com \
    --to=zimon.toutoune@gmail.com \
    --cc=43261@debbugs.gnu.org \
    --cc=ludo@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).