From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id SO/lAL6lmV+VfwAA0tVLHw (envelope-from ) for ; Wed, 28 Oct 2020 17:09:18 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id MLVGOL2lmV8HBgAAB5/wlQ (envelope-from ) for ; Wed, 28 Oct 2020 17:09:17 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 7C2ED940630 for ; Wed, 28 Oct 2020 17:09:17 +0000 (UTC) Received: from localhost ([::1]:36568 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kXowm-0007kK-FR for larch@yhetil.org; Wed, 28 Oct 2020 13:09:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40778) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kXog9-0003bG-7x for guix-patches@gnu.org; Wed, 28 Oct 2020 12:52:05 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:38844) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kXog6-0002a1-9m for guix-patches@gnu.org; Wed, 28 Oct 2020 12:52:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kXog6-000503-92 for guix-patches@gnu.org; Wed, 28 Oct 2020 12:52:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#43261] [PATCH v2 2/2] scripts: lint: Add '--exclude' option. Resent-From: zimoun Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 28 Oct 2020 16:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43261 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 43261@debbugs.gnu.org Cc: ludo@gnu.org, zimoun Received: via spool by 43261-submit@debbugs.gnu.org id=B43261.160390389219172 (code B ref 43261); Wed, 28 Oct 2020 16:52:02 +0000 Received: (at 43261) by debbugs.gnu.org; 28 Oct 2020 16:51:32 +0000 Received: from localhost ([127.0.0.1]:50389 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kXofc-0004zA-E5 for submit@debbugs.gnu.org; Wed, 28 Oct 2020 12:51:32 -0400 Received: from mail-wm1-f42.google.com ([209.85.128.42]:38917) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kXofY-0004yf-05 for 43261@debbugs.gnu.org; Wed, 28 Oct 2020 12:51:28 -0400 Received: by mail-wm1-f42.google.com with SMTP id d3so224177wma.4 for <43261@debbugs.gnu.org>; Wed, 28 Oct 2020 09:51:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zyGHYMuOUG9SI+erhkP2hv4dqLyoSKx1z1vxYaZ9MO8=; b=lvPDkGfPW/BEXjAznOeP7oTu2tjTpL/fp63MSXM0nMf/rlzAWfd3QyjS6xICRsTt43 fYZe9vxmTfH5O/67C+BSA/SjNYOyRVeukD45oPyRVKtMvKi3jQHuzqhL4wzV7hS5pGgf 6Bgxnrp0Uf+/hL25ebOICk8j6vcs/V8JG2hQkbCdUwH6hKy/2BHed8dugjhwtk7ptKDB PHKRZU81k5MGM78Q//IoD5PaH4w2wT9QoM+iJNQOKDd1Z5qGGWU2EfVt17q5c7EufPCa GpWMU4yUP8xIhlaiPIZ5lhkez7wH9vF2AtPEClpcv9FCHz2M2tif2Dg3s00XVGcHjU+9 zysg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zyGHYMuOUG9SI+erhkP2hv4dqLyoSKx1z1vxYaZ9MO8=; b=M4szBZkklJ6xF8xsvMNtdLUXpNDQktE0437dX7JwqOSif3i2TZzIkuoD+2E4FWAtnV Z8XC0e1xzYgHBGDKadE82t/MMBZw+r5cyV2LsbvCFzn+V9wXJXAxpVCYoKxfFmYY3u5k ApPXDl3aJzDIaR16tHcu+3MVEl1FFfYy4bRbC6QPoiftnGPOIkLb88wAEDjPLrdoBMws Zy1ZTBV4dcTbcP2lmjNh/1xzkmJ3OqIlEPAuT07ZBTtXSgNpZCJQj9d6ayoPS5bAoQFm 1TLAQNvshZohAXDiy6/V7NH3Ji0DKzsx5ZIhmjcl4cYvcuIhpWMWLFWpRzm6AAJ/xP+/ 8mNA== X-Gm-Message-State: AOAM531DSyUilE8suT1Z1AP/+SiHHmzSUTF0ONUcspVD6tu9RWOvX0z/ QutVhoD5ecX85+0bHzBZvUsDnopcHi4= X-Google-Smtp-Source: ABdhPJyPpuV2ydDJltGuJ3Wh8FE7rBsYQ1Fr6GGnt+j/NKH+UqEWkvbFssc16WQ9mZlxEs9Neuimqg== X-Received: by 2002:a7b:c20d:: with SMTP id x13mr335105wmi.83.1603903881773; Wed, 28 Oct 2020 09:51:21 -0700 (PDT) Received: from lili.univ-paris-diderot.fr ([2a01:e0a:59b:9120:65d2:2476:f637:db1e]) by smtp.gmail.com with ESMTPSA id y206sm221247wmd.34.2020.10.28.09.51.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Oct 2020 09:51:21 -0700 (PDT) From: zimoun Date: Wed, 28 Oct 2020 17:51:12 +0100 Message-Id: <20201028165112.28575-2-zimon.toutoune@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201028165112.28575-1-zimon.toutoune@gmail.com> References: <20201028165112.28575-1-zimon.toutoune@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -1.0 (-) X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=fail (rsa verify failed) header.d=gmail.com header.s=20161025 header.b=lvPDkGfP; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Spam-Score: 4.09 X-TUID: DwdVGV4GXbl8 * 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