From unknown Tue Aug 19 21:02:34 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#61266 <61266@debbugs.gnu.org> To: bug#61266 <61266@debbugs.gnu.org> Subject: Status: [PATCH 1/1] lint: Add unused-modules linter. Reply-To: bug#61266 <61266@debbugs.gnu.org> Date: Wed, 20 Aug 2025 04:02:34 +0000 retitle 61266 [PATCH 1/1] lint: Add unused-modules linter. reassign 61266 guix-patches submitter 61266 Reily Siegel severity 61266 normal tag 61266 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Sat Feb 04 01:45:43 2023 Received: (at submit) by debbugs.gnu.org; 4 Feb 2023 06:45:43 +0000 Received: from localhost ([127.0.0.1]:40505 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOCIu-00022v-75 for submit@debbugs.gnu.org; Sat, 04 Feb 2023 01:45:43 -0500 Received: from lists.gnu.org ([209.51.188.17]:39434) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOCIs-00022n-Ks for submit@debbugs.gnu.org; Sat, 04 Feb 2023 01:45:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOCIr-0001lT-KS for guix-patches@gnu.org; Sat, 04 Feb 2023 01:45:37 -0500 Received: from mout-p-103.mailbox.org ([80.241.56.161]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim 4.90_1) (envelope-from ) id 1pOCIp-0008V6-B2 for guix-patches@gnu.org; Sat, 04 Feb 2023 01:45:37 -0500 Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-103.mailbox.org (Postfix) with ESMTPS id 4P831l1mlYz9scc for ; Sat, 4 Feb 2023 07:45:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=reilysiegel.com; s=MBO0001; t=1675493131; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=+zxGffCQ1EjRI7VC0CR+EaiCnUejpi84nXrqASlg1mw=; b=pwpu2jzjgdivKHuidVrfw57KEUKAgeU1GQpVz6wexW0iKWrwHtJ1fk2AYespKKZscyjKrJ fcbtVYtDeWQS6A/h42jv7st72shk1Uv+TimYMeTZyE9Hk/NdmvzY1xBoiFQRdFtbp+5qQF z9cevoigau1JZhUl0B1BbfRYCS9i4PvAYHHbbwkyCqoFVEnRRrOP0zokDXTp711qUsQn35 NsY42DVHiq+rIDuOtj2k/5ehOA7km4ynx6G+YgNfSjvcUgPt4hjn7zSPB3BSI+6v7oEBRi Aqp08gyluUe5+63iPmwj69+Slc/TKUe+/mms8gATFKk7XEi/drSuev8PeY97Pw== From: Reily Siegel To: guix-patches@gnu.org Subject: [PATCH 1/1] lint: Add unused-modules linter. Date: Sat, 4 Feb 2023 00:59:42 -0500 Message-ID: <87h6w2gc8n.fsf@reilysiegel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=80.241.56.161; envelope-from=mail@reilysiegel.com; helo=mout-p-103.mailbox.org X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.6 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.6 (--) * guix/lint.scm (file-module): New function. (module-dependencies): New function. (sexp-symbols): New function. (file-symbols): New function. (report-unused-module): New function. (check-unused-modules): New function. (%local-checkers): Add check-unused-modules. --- guix/lint.scm | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/guix/lint.scm b/guix/lint.scm index 8e3976171f..38c8595bd6 100644 --- a/guix/lint.scm +++ b/guix/lint.scm @@ -14,6 +14,7 @@ ;;; Copyright =C2=A9 2021 Xinglu Chen ;;; Copyright =C2=A9 2021, 2022 Maxime Devos ;;; Copyright =C2=A9 2021 Brice Waegeneire +;;; Copyright =C2=A9 2023 Reily Siegel ;;; ;;; This file is part of GNU Guix. ;;; @@ -37,6 +38,7 @@ (define-module (guix lint) #:autoload (guix base64) (base64-encode) #:use-module (guix build-system) #:use-module (guix diagnostics) + #:use-module (guix discovery) #:use-module (guix download) #:use-module (guix ftp-client) #:use-module (guix http-client) @@ -1843,6 +1845,62 @@ (define (check-formatting package) (G_ "source file not found")))))))) '()))) =20 +(define (file-module file) + "Return the resolved module defined in FILE." + (call-with-input-file file + (lambda (port) + (let loop () + (match (read port) + (('define-module module . _) (resolve-module module)) + ((? eof-object?) #f) + (_ (loop))))))) + +(define (module-dependencies module) + "Return an alist of (module . public-exports) for each of MODULE's impor= ts." + (fold-module-public-variables* + (lambda (module sym _ alist) + (assoc-set! alist module (cons sym (or (assoc-ref alist module) '()))= )) + '() + (module-uses module))) + +(define (sexp-symbols sexp) + "Return all symols in SEXP." + (match sexp + ((? symbol?) (list sexp)) + ((? list?) (apply append (map sexp-symbols sexp))) + (_ '()))) + +(define (file-symbols file) + "Return all symbols in FILE." + (call-with-input-file file + (lambda (port) + (let loop ((res '())) + (let ((sexp (read port))) + (if (eof-object? sexp) + res + (loop (append res (sexp-symbols sexp))))))))) + +(define (report-unused-module package module) + "Report a warning that MODULE is not used in the file where PACKAGE is d= efined." + (make-warning package + (G_ "Imported module ~a is not used.") + (list (module-name module)))) + +(define (check-unused-modules package) + "Check if the file in which PACKAGE is defined contains unused module im= ports." + (let* ((file (package-file package)) + (symbols (file-symbols file)) + (dependencies (module-dependencies (file-module file)))) + (fold + (match-lambda* + (((module . publics) res) + (if (null? (lset-intersection eq? publics symbols)) + (cons (report-unused-module package module) + res) + res))) + '() + dependencies))) + ;;; ;;; List of checkers. @@ -1922,7 +1980,11 @@ (define %local-checkers (lint-checker (name 'formatting) (description "Look for formatting issues in the source") - (check check-formatting)))) + (check check-formatting)) + (lint-checker + (name 'unused-modules) + (description "Look for unused modules in the package file") + (check check-unused-modules)))) =20 (define %network-dependent-checkers (list From debbugs-submit-bounces@debbugs.gnu.org Sat Feb 04 02:37:52 2023 Received: (at control) by debbugs.gnu.org; 4 Feb 2023 07:37:52 +0000 Received: from localhost ([127.0.0.1]:40538 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOD7Q-0003zH-Cb for submit@debbugs.gnu.org; Sat, 04 Feb 2023 02:37:52 -0500 Received: from mail-ed1-f65.google.com ([209.85.208.65]:41975) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOD7M-0003z2-3M for control@debbugs.gnu.org; Sat, 04 Feb 2023 02:37:51 -0500 Received: by mail-ed1-f65.google.com with SMTP id v10so7075789edi.8 for ; Fri, 03 Feb 2023 23:37:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:user-agent:content-transfer-encoding:date:to:from :subject:message-id:from:to:cc:subject:date:message-id:reply-to; bh=zx1iTwnZA2uAgux3j0QqQavyGpKJ94mpCL/rgDYNgDw=; b=RILIhNsmL63WltX6nLz31Gh2i54Vfn60xAr/60TRSaYGMm6WoOi4OdGeP8yCuGBZ3Y 3GCWSbaGMOzXLZ9EGJUg7zDBbBxNzYBdV4AQsePN1u7ruumMRUt/CS6sHgIpOlbV1cie HZJOlevCK0M9fZpaf+h6QLwGy3/71CAZwCfr29/bbs3jR8F3tZMjQ8K+At5qBL+caKpS NiOiou0Y4MQ22nOF5uvmU9HIFenelZrlRR0J7bLJcrotQkPE14kjPaFw/8DTeIe4Llz3 y1qbvzGu+PKZwcgfQ+XaHMshG1cga7ENDLkna5jlUSQORh/5rS99yjyO/MIt/CEGeIAb S9KA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:content-transfer-encoding:date:to:from :subject:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=zx1iTwnZA2uAgux3j0QqQavyGpKJ94mpCL/rgDYNgDw=; b=fMYZkhwpDAWpa4YVDLXOONFjbd6OaM5uoENfnSvDvSead9aUa3i0AMb/TeJ9cxfRtN spI9WFINhIGACbQtoUwuhTxHgHPR7/D4XDJZNkFVk4CAgYT36xYBTT+0bWLKgMieJfcU zF/JXIGl7kYwpSAQtZG7AMvICEAZyKkVFQZOdzZpAhsa/Cq8UK8XZddOMx3LJlHs7hjE b994pNho1LQz+HoczXFyExLTSFz7/cT3N8NTvNgvszVY139HRfjKavZNmWCxpMxfBz1T KDJnXa8+VSbVUM4tauhfVM1/HKttde52g5HP4KGh9S6VuJ2mAzTe1Oc/phy89oAw+779 KFOQ== X-Gm-Message-State: AO0yUKXt25epVQs3rKlUG7h/l1sXTGQGw5VHeHvrrMC5EKznpd94ilGj wk0L3l7JeWyDs8DxLjMcJZlZOr/r+j8= X-Google-Smtp-Source: AK7set/DtDf1h80skuq81Y8ioGbNUXrwcftPerLaHZz/Lexn47VenC2M3O0JpZt+dY/emZTPuSGrrA== X-Received: by 2002:a50:9fef:0:b0:45c:835b:ac64 with SMTP id c102-20020a509fef000000b0045c835bac64mr14244806edf.31.1675496262223; Fri, 03 Feb 2023 23:37:42 -0800 (PST) Received: from lumine.fritz.box (85-127-52-93.dsl.dynamic.surfer.at. [85.127.52.93]) by smtp.gmail.com with ESMTPSA id b11-20020aa7c6cb000000b004a986403dc1sm1674039eds.1.2023.02.03.23.37.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Feb 2023 23:37:41 -0800 (PST) Message-ID: <322002423076ce48f8fbd0c74e59cdda565178c9.camel@gmail.com> Subject: From: Liliana Marie Prikler To: control@debbugs.gnu.org Date: Sat, 04 Feb 2023 08:37:40 +0100 Content-Type: text/plain Content-Transfer-Encoding: 7bit User-Agent: Evolution 3.46.0 MIME-Version: 1.0 X-Spam-Score: 3.3 (+++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: merge 61265 61266 thanks Content analysis details: (3.3 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (liliana.prikler[at]gmail.com) 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 1.3 RCVD_IN_VALIDITY_RPBL RBL: Relay in Validity RPBL, https://senderscore.org/blocklistlookup/ [209.85.208.65 listed in bl.score.senderscore.com] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.208.65 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.208.65 listed in list.dnswl.org] 2.0 BLANK_SUBJECT Subject is present but empty X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 2.3 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: merge 61265 61266 thanks Content analysis details: (2.3 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.208.65 listed in wl.mailspike.net] 1.3 RCVD_IN_VALIDITY_RPBL RBL: Relay in Validity RPBL, https://senderscore.org/blocklistlookup/ [209.85.208.65 listed in bl.score.senderscore.com] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.208.65 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (liliana.prikler[at]gmail.com) 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 2.0 BLANK_SUBJECT Subject is present but empty -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager merge 61265 61266 thanks From debbugs-submit-bounces@debbugs.gnu.org Sun Feb 05 08:08:10 2023 Received: (at control) by debbugs.gnu.org; 5 Feb 2023 13:08:10 +0000 Received: from localhost ([127.0.0.1]:44346 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOekc-00057H-4m for submit@debbugs.gnu.org; Sun, 05 Feb 2023 08:08:10 -0500 Received: from new4-smtp.messagingengine.com ([66.111.4.230]:36711) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOeka-000574-T8 for control@debbugs.gnu.org; Sun, 05 Feb 2023 08:08:09 -0500 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailnew.nyi.internal (Postfix) with ESMTP id D3CEE581DF4; Sun, 5 Feb 2023 08:08:03 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Sun, 05 Feb 2023 08:08:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=famulari.name; h=cc:content-type:date:date:from:from:in-reply-to:message-id :mime-version:reply-to:sender:subject:to:to; s=mesmtp; t= 1675602483; x=1675609683; bh=DQDpOMqTxCQ3czKVgFFUCxk69i1YpSCkauD 7n50Sd/0=; b=RFiLKdMR+buEUsP9RF2CzHlV0N5lhgT9xY3eAmXJ42l3VY+ZoNZ 17EOiXnO5AvrKkGqa3VqyoF3TI0PaCxhLkfIPCgppiuduiKIGThbNHqNqtmi01EN w3fCgnfg533RPhLN9kbFN7EV90dAYogMyId3fWOh290l6Wni2ej9K9Qc= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:message-id:mime-version :reply-to:sender:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1675602483; x=1675609683; bh=D QDpOMqTxCQ3czKVgFFUCxk69i1YpSCkauD7n50Sd/0=; b=XmCCKsXiiasHa6zgd NZ6Vzyxo05LmQruFrS/GvxTw5vEsoJEQw4atBH2706oN3l6y/n8LFICYDJpM6MgV qQNsY9AKd5hrR9koteq0ARX/wdqNDcp/gEmjAvwfhXwN1ScsuPv2rEg5B14T/dJT qVfav4QARMm39kMLHwkrFda9aam7NZiclqIiShbSljI0oQqvbDOoI8C3CTWYalrX 6Qa5BJLPG9FzJY9OGE6ksONUyRkf7hZUSFrb8Y/HIq7RbKa0S5216mDOnfXgQVVp PHq/iC+E3voASxYwiMw2uchwwmxMzw3k8uZvBHL1sYl3Xx8pGEdHdCXv2uL9OvWK RgP6Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudeggedggeekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucfgmhhpthihuchsuhgsjhgvtghtucdluddtmdenuc fjughrpeffhffvkfggtggusehttdertddttddvnecuhfhrohhmpefnvghoucfhrghmuhhl rghrihcuoehlvghosehfrghmuhhlrghrihdrnhgrmhgvqeenucggtffrrghtthgvrhhnpe fhjeeigfefvedvfeetheegledtkeevuddtgedtudeiteehteegvdefffduffefffenucev lhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehlvghosehfrg hmuhhlrghrihdrnhgrmhgv X-ME-Proxy: Feedback-ID: i819c4023:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Sun, 5 Feb 2023 08:08:03 -0500 (EST) Date: Sun, 5 Feb 2023 14:08:01 +0100 From: Leo Famulari To: control@debbugs.gnu.org Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Score: 1.3 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: merge 61265 61266 Content analysis details: (1.3 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [66.111.4.230 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 1.8 MISSING_SUBJECT Missing Subject: header 0.2 NO_SUBJECT Extra score for no subject X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.3 (/) merge 61265 61266 From debbugs-submit-bounces@debbugs.gnu.org Sat Feb 11 18:56:13 2023 Received: (at 61266) by debbugs.gnu.org; 11 Feb 2023 23:56:13 +0000 Received: from localhost ([127.0.0.1]:43529 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pQzj2-0008Gd-JG for submit@debbugs.gnu.org; Sat, 11 Feb 2023 18:56:12 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53872) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pQzix-0008GB-1G for 61266@debbugs.gnu.org; Sat, 11 Feb 2023 18:56:11 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pQzir-0007vt-0O; Sat, 11 Feb 2023 18:56:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=csbU6iGcUcBtmGccErXQdbY8G80dLVumVhpqfBT0IsY=; b=irRv2YXfiEEOJILN6coL Fdnn8l5kHfACRrve3ZBTG5ocIEhqjLum7EL5L4L4le1m4s52Nt/CcMCoXzDB8+C2KsncqW4WBuKtD h2gm6MP6i0LENUFIRaUMy7biEQ8FioBbecrHEpHlDBLMY1MhlAUxs8Vp+p1goA8LzfmCYzZrvgTP6 9Uq0DSpNBq/qdYjBGmNTF+fJCEtX0zhWxziUBdbMA5Dda/VVydR5T0Y1Ug1ZKq2o9Z2Q4gpQx4Y79 iZvJhTSuWZ43AC0+ZPQ1X68AFHUhwf9xmOrkojeS99/EB+Lnbvbc4Nrh48E5dtvm/A5y3Kb8qy5fW sNMjXW7d5VMIeg==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201] helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pQziq-0003WK-JO; Sat, 11 Feb 2023 18:56:00 -0500 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Reily Siegel Subject: Re: bug#61266: [PATCH 1/1] lint: Add unused-modules linter. References: <87h6w2gc8n.fsf@reilysiegel.com> Date: Sun, 12 Feb 2023 00:55:58 +0100 In-Reply-To: <87h6w2gc8n.fsf@reilysiegel.com> (Reily Siegel's message of "Sat, 4 Feb 2023 00:59:42 -0500") Message-ID: <87y1p3n4dt.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 61266 Cc: 61266@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi Reily, Reily Siegel skribis: > * guix/lint.scm (file-module): New function. > (module-dependencies): New function. > (sexp-symbols): New function. > (file-symbols): New function. > (report-unused-module): New function. > (check-unused-modules): New function. > (%local-checkers): Add check-unused-modules. Nice! This is a hot topic, discussed at the Guix Days last week! https://lists.gnu.org/archive/html/guix-devel/2023-02/msg00028.html [...] > +(define (check-unused-modules package) > + "Check if the file in which PACKAGE is defined contains unused module = imports." > + (let* ((file (package-file package)) > + (symbols (file-symbols file)) > + (dependencies (module-dependencies (file-module file)))) > + (fold > + (match-lambda* > + (((module . publics) res) > + (if (null? (lset-intersection eq? publics symbols)) > + (cons (report-unused-module package module) > + res) > + res))) > + '() > + dependencies))) As you may know, this is an approximation: it doesn=E2=80=99t take into acc= ount shadowed bindings, module import renamers and selections, and so on; it might think a module is used just because a symbol with the same name as one it exports appears somewhere in the code. In practice, it probably works quite well for package modules though, right? I have just submitted a patch adding a =E2=80=98-Wunused-module=E2=80=99 wa= rning to Guile=E2=80=99s compiler, which avoids these issues: https://lists.gnu.org/archive/html/guile-devel/2023-02/msg00026.html I wonder if we should stick to that and avoid having a lint warning altogether. WDYT? Thanks, Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Mon Feb 13 13:21:13 2023 Received: (at 61266) by debbugs.gnu.org; 13 Feb 2023 18:21:13 +0000 Received: from localhost ([127.0.0.1]:51537 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pRdRw-0002ww-U3 for submit@debbugs.gnu.org; Mon, 13 Feb 2023 13:21:13 -0500 Received: from mout-p-202.mailbox.org ([80.241.56.172]:50058) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pRdRv-0002wc-8C for 61266@debbugs.gnu.org; Mon, 13 Feb 2023 13:21:11 -0500 Received: from smtp102.mailbox.org (smtp102.mailbox.org [10.196.197.102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4PFt271DtGz9sTL; Mon, 13 Feb 2023 19:21:03 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=reilysiegel.com; s=MBO0001; t=1676312463; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Cx5ISdbDZiuYCpR23JLnUdfkvxcxwMo2LypW9wcSJmg=; b=zcArOVckr90521iJqqjz+qVJ0mYdUOCEpM6v8UydB5+BLta2xuuEysTk4UX8OiFZUf1jJ+ 8Obkyi6KSRKOU4xhzEdC1lHZi78nd8gSpSV1W/3JZuHYvfsvrhKLJPvCUGkCc+j3zeUXuC 7CnmRq1X4DO9W7CtuyJ+nq55F9Rvf1PSXOY8o56EyEor7cQLZm7gx/D3NLX4MKxdrlXA61 Elra8dghGeR6coCQ7OPuTbkALiHO5X4DJLOBMsqzizPFtaPvP8Lcef4yfaajOY5pGHAo1G v9TSwbibNxFBNoLpCnyjuSIdXm/VOtnCMBhzI1OKk0FBvzI41xJc5EVhYR4HgA== From: Reily Siegel To: Ludovic =?utf-8?Q?Court=C3=A8s?= Subject: Re: bug#61266: [PATCH 1/1] lint: Add unused-modules linter. In-Reply-To: <87y1p3n4dt.fsf@gnu.org> References: <87h6w2gc8n.fsf@reilysiegel.com> <87y1p3n4dt.fsf@gnu.org> Date: Mon, 13 Feb 2023 13:20:49 -0500 Message-ID: <87y1p1a0la.fsf@reilysiegel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 61266 Cc: 61266@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Ludovic Court=C3=A8s writes: > I have just submitted a patch adding a =E2=80=98-Wunused-module=E2=80=99 = warning to > Guile=E2=80=99s compiler, which avoids these issues: > > https://lists.gnu.org/archive/html/guile-devel/2023-02/msg00026.html > > I wonder if we should stick to that and avoid having a lint warning > altogether. WDYT? This is probably a much more workable approach. Another problem with lint checkers that I forgot to mention in my initial patch is that they are really designed to work on packages, not files. -- Reily Siegel From debbugs-submit-bounces@debbugs.gnu.org Mon Feb 20 05:53:55 2023 Received: (at 61266-done) by debbugs.gnu.org; 20 Feb 2023 10:53:55 +0000 Received: from localhost ([127.0.0.1]:50619 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pU3nv-0004GN-5A for submit@debbugs.gnu.org; Mon, 20 Feb 2023 05:53:55 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52338) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pU3nu-0004GC-3b for 61266-done@debbugs.gnu.org; Mon, 20 Feb 2023 05:53:54 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pU3nn-0002hH-K5; Mon, 20 Feb 2023 05:53:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=qzJzJDJYiLWwltX0BfVE5SkpjoNpXryEuU0aoZoYIiQ=; b=XoNz6hPYe7nCEwmEaUG0 D9va2ZHf/UdJwiVjcS5Eheb/wZxn2L2tVXuUKJg/Q5nMPaCkX1wFOVaFlAvDC8t6ujrPWDB0Y1fNZ eA6ntu1InmB3kLljGhk8QGZ06B55G9JfhNNu1HNxD/wkKtpZvfdgbR5y73x2aTfs08kIHIP6qWJjK ZziwLVyLBubHwT8hlHgsK/u5ZMZ0IdjMPiHR2Sdhv6UrifEGTaYj+NqL1xyxbJb/1KaamNH0olQlg SnHYpCC0lVjbpSoMpT0dHz7HEPTIb82PJbZY6tfOzrsYqYz02lJcatUp0DuyM4PYCmrJtWZT0xu67 abOmdvt7bO6CYA==; Received: from [193.50.110.154] (helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pU3nn-0004sy-3v; Mon, 20 Feb 2023 05:53:47 -0500 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Reily Siegel Subject: Re: bug#61266: [PATCH 1/1] lint: Add unused-modules linter. References: <87h6w2gc8n.fsf@reilysiegel.com> <87y1p3n4dt.fsf@gnu.org> <87y1p1a0la.fsf@reilysiegel.com> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: Duodi 2 =?utf-8?Q?Vent=C3=B4se?= an 231 de la =?utf-8?Q?R=C3=A9volution=2C?= jour du Cornouiller X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Mon, 20 Feb 2023 11:53:45 +0100 In-Reply-To: <87y1p1a0la.fsf@reilysiegel.com> (Reily Siegel's message of "Mon, 13 Feb 2023 13:20:49 -0500") Message-ID: <87zg98ip52.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 61266-done Cc: 61266-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi Reily, Reily Siegel skribis: > Ludovic Court=C3=A8s writes: > >> I have just submitted a patch adding a =E2=80=98-Wunused-module=E2=80=99= warning to >> Guile=E2=80=99s compiler, which avoids these issues: >> >> https://lists.gnu.org/archive/html/guile-devel/2023-02/msg00026.html >> >> I wonder if we should stick to that and avoid having a lint warning >> altogether. WDYT? > > This is probably a much more workable approach. Another problem with > lint checkers that I forgot to mention in my initial patch is that they > are really designed to work on packages, not files. Alright, I=E2=80=99m closing this issue but let=E2=80=99s reopen it if we e= ventually change our mind. Thanks for looking into this! Ludo=E2=80=99. From unknown Tue Aug 19 21:02:34 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Mon, 20 Mar 2023 11:24:10 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator