From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id QINwMBD/3WNpLwEAbAwnHQ (envelope-from ) for ; Sat, 04 Feb 2023 07:45:36 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id 2I14MBD/3WOYdQEA9RJhRA (envelope-from ) for ; Sat, 04 Feb 2023 07:45:36 +0100 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 8B3A61086A for ; Sat, 4 Feb 2023 07:45:36 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pOCIM-0001gt-PU; Sat, 04 Feb 2023 01:45:06 -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 1pOCIK-0001gZ-VW for guix-patches@gnu.org; Sat, 04 Feb 2023 01:45:05 -0500 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pOCII-0008H1-Ex for guix-patches@gnu.org; Sat, 04 Feb 2023 01:45:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pOCII-0000Iq-A7 for guix-patches@gnu.org; Sat, 04 Feb 2023 01:45:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#61265] [PATCH 0/1] Add lint checker for unused module imports. Resent-From: Reily Siegel Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 04 Feb 2023 06:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 61265 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 61265@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.16754930421001 (code B ref -1); Sat, 04 Feb 2023 06:45:02 +0000 Received: (at submit) by debbugs.gnu.org; 4 Feb 2023 06:44:02 +0000 Received: from localhost ([127.0.0.1]:40500 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOCHJ-0000Fr-H0 for submit@debbugs.gnu.org; Sat, 04 Feb 2023 01:44:02 -0500 Received: from lists.gnu.org ([209.51.188.17]:59144) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOCHI-0000Fk-1q for submit@debbugs.gnu.org; Sat, 04 Feb 2023 01:44:01 -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 1pOCHH-0001cR-JP for guix-patches@gnu.org; Sat, 04 Feb 2023 01:43:59 -0500 Received: from mout-p-102.mailbox.org ([2001:67c:2050:0:465::102]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim 4.90_1) (envelope-from ) id 1pOCHF-0008Ad-Sy for guix-patches@gnu.org; Sat, 04 Feb 2023 01:43:59 -0500 Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::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-102.mailbox.org (Postfix) with ESMTPS id 4P82zm3X1Jz9sZr for ; Sat, 4 Feb 2023 07:43:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=reilysiegel.com; s=MBO0001; t=1675493028; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=S7Mw8FpIcvjAprreWijAdKtyngzOH7wDe0gaxjJuOFo=; b=0K9uO0tKkTHxFLcYq0EOgbPhlx3KRqRJ113sOmkzjL3iIf2jbYF7pFQT/sqqaSWt1jWlAt yCk7M6f2NvaWnQbEKAFbab+/K26+F7wnG3wkJocEt0D+IrGKQiQsQ7h+gEZhn4oOOBYSU1 o3ImaevrtteY+Rio1KhNFttKwhgvypuBpY2qaedTD3Q02TpejZ38FpKrGDYXsszN6ilA/q Nj5vFoj/KHGGC5/GxxHejf9tvTyRoncR1pt72s6FeAYfCExgPLLsdvriNOipkjoGaU0ATA 74X5VFEFI3L+OyQ7Q7lAUb5qe51I5YZv/kn0js4XyHURQLub43QkkZgWJ0vAhg== From: Reily Siegel Date: Sat, 4 Feb 2023 01:42:28 -0500 Message-ID: <87lelegcbm.fsf@reilysiegel.com> MIME-Version: 1.0 Content-Type: text/plain X-Rspamd-Queue-Id: 4P82zm3X1Jz9sZr Received-SPF: pass client-ip=2001:67c:2050:0:465::102; envelope-from=mail@reilysiegel.com; helo=mout-p-102.mailbox.org X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1675493136; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:list-id:list-help:list-unsubscribe:list-subscribe: list-post:dkim-signature; bh=S7Mw8FpIcvjAprreWijAdKtyngzOH7wDe0gaxjJuOFo=; b=QKk8YE677qw0CbFhpXw/eBYbpYd0tCotKEmxVxKRFRjChppBo9n8s/9nKWZDqwbFmokPV/ fQp7fEwulRkgQ/u/yNGUIhUC2MeL8ngOWmnYgxA0TnTVMcMyHOvTAn0yRWRXQaJRStghyY 63OuBBuam/bUO3Vdpor8h5aF7ZNJ8QXkN7Ijhf1Bwe5w8j8W5Fd72oFZ79gAbapeOPIuIB i5uIfnCRfmHk92NV4AOs11G2ONNwLC68TH+C+ckKmrwwyk/HN56sPnFH77676iwIgo+Pm+ Pelub99Ltxq84Jn/h8M6dUguLxbNmZZH6EfP3gXgvboYo5Q2sGHrcyCCeg4Oiw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=reilysiegel.com header.s=MBO0001 header.b=0K9uO0tK; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=none ARC-Seal: i=1; s=key1; d=yhetil.org; t=1675493136; a=rsa-sha256; cv=none; b=B4n26TNgHrmCvARP6+yRH40MCj4tJSgpnaFJlvhF7yGQup3WuPK/Zc705cEPOSMBlNo8HO dQ0qqbacR8SvmlJGXEgrtdtRrwsWFqdKnq55FO3P4Gfp7VZBcLRT/URyCDjaQNTUPeo5Gr S8xGEyefYf2R2lRLc3rWU2udl5SGpyJ0YgYxTiZzmEZufozzgibzQKqwF+mNEZfGG7G4x5 xZIhNj4nyYHm4AwRybrTupODkC6bAdjS9y5gsUu9fTfr+4/GX/80Mvo4UAHNSr5z4UYgBx amz+A9r0vITWk6Sx11DaSPBnIEoJr0IgCV5gjBf3BPONrCbqppJ1OqFlLMEX+A== X-Migadu-Spam-Score: -0.98 X-Spam-Score: -0.98 X-Migadu-Queue-Id: 8B3A61086A Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=reilysiegel.com header.s=MBO0001 header.b=0K9uO0tK; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=none X-Migadu-Scanner: scn1.migadu.com X-TUID: mfYTOTC+Jmyq Julien Lepiller writes (guix-devel): > Many modules seem to use a lot of imports that are actually useless, > for instance (gnu packages heads) imports 20 package modules, but > only uses 4 of them. > > Removing these module imports would help a lot with reducing the number > of loops. If anyone wants to volunteer a lint checker for that, > raise hands :D This is a quick and dirty implementation of such a lint checker. It compares the symbols used in a module to those provided by its dependencies. If there is a dependency for which none of the symbols overlap, a warning is reported. A potential downside of this approach is that the lint checker cannot distinguish between lexically scoped variables and variables which actually reference another module. This has two effects: - The implementation is slower, because lexically bound variables must also be checked - The implementation may fail to report an unused import if a lexical binding with the same name as one of the module's exports is used However, this does vastly simplify the implementation. Reily Siegel (1): lint: Add unused-modules linter. guix/lint.scm | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-)