From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id uCwbBXx8pmDy7AAAgWs5BA (envelope-from ) for ; Thu, 20 May 2021 17:13:00 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id CJbFAHx8pmCOaQAAbx9fmQ (envelope-from ) for ; Thu, 20 May 2021 15:13:00 +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 C386C23BB1 for ; Thu, 20 May 2021 17:12:59 +0200 (CEST) Received: from localhost ([::1]:51822 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ljkM6-0001jd-US for larch@yhetil.org; Thu, 20 May 2021 11:12:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40894) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljk91-0008LB-BQ for guix-devel@gnu.org; Thu, 20 May 2021 10:59:27 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:35236) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ljk90-0001mv-QI; Thu, 20 May 2021 10:59:26 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=45618 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ljk90-0005bZ-8Q; Thu, 20 May 2021 10:59:26 -0400 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= To: guix-devel@gnu.org Subject: [PATCH RFC 4/4] DRAFT lint: Add 'input-labels' checker. Date: Thu, 20 May 2021 16:58:30 +0200 Message-Id: <20210520145830.14108-5-ludo@gnu.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520145830.14108-1-ludo@gnu.org> References: <20210520145830.14108-1-ludo@gnu.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: "Guix-devel" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1621523579; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ED5nfSBIkwsyHRy/f8rkiVMMPPoJw7gFC1YRE9u2tJs=; b=nii0GKcTNNWzfnQbybXk4vtW1sJaHVzWKToIQYEMSL5aIna1SF20S8dvyXPtcr1IDrdqnY jjL5YWK9PyxzE3hpQw5Ag6UoFXXUtspSD0dGayeqrW4z2Y/MiFYti1DssGirabOIYwk5Fc RZuGiwE3dJgVpdv46W83pUcJsMIbDifGiVzDl3poqcMXzsruiTXl2Tz+fiMSwiCLS1BccI D7IBGEsvzHBq5zoYMfJJ3LrYrxiKW+sLv5lK86/66qeD5+KKzJAKGT8XWyZXz44iGcF6sK 3sZwTGQZ6xS5LQ1U/NAg60wDeU8q0ElGLLYWXFaGVaQlUak2nsH6jAW68863iQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1621523579; a=rsa-sha256; cv=none; b=KWN+MYf5/RFk1rGcXWdYMrrrCDbX0bJS8xtMOA62IXTVQPzB5OMmeKwvPXokusgtkgxK/q 1hDfpQhfI41CV8fzD9ZLVmrGPyRD0ZjzRzF1RVQvE1MIg7SBabtZsXwcUP38AgQt2g4uoK SuVVbDR9l+T18vmyzqpTPwHJGYHW9GGVjA2mwAXoVgwvQxqZO4y14l1fVkMsFJlG0hCr7r WOjBYGf5XJjE/La9vkxQmVgImpoE9qQDwWGJ4mxNzbhxnnWbrEtSQP4oMW2X/UL89+JkkS +SFq4eESONb3gFsjR83lvEqD0ooz/nbK3mi28tIQ859/+RHwceDDWdQ+J0YIpA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; spf=pass (aspmx1.migadu.com: domain of guix-devel-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-devel-bounces@gnu.org X-Migadu-Spam-Score: 2.06 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-devel-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-devel-bounces@gnu.org X-Migadu-Queue-Id: C386C23BB1 X-Spam-Score: 2.06 X-Migadu-Scanner: scn0.migadu.com X-TUID: 2EsdHR+bY3A+ DRAFT: Good idea? If yes, add tests and doc. * guix/lint.scm (check-input-labels): New procedure. (%local-checkers): Add 'input-labels' checker. --- guix/lint.scm | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/guix/lint.scm b/guix/lint.scm index 1bebfe03d3..95f82dba60 100644 --- a/guix/lint.scm +++ b/guix/lint.scm @@ -383,6 +383,37 @@ of a package, and INPUT-NAMES, a list of package specifications such as (package-input-intersection (package-direct-inputs package) input-names)))) +(define (check-input-labels package) + "Emit a warning for labels that differ from the corresponding package name." + (define (check input-kind package-inputs) + (define (warning label name) + (make-warning package + (G_ "label '~a' does not match package name '~a'") + (list label name) + #:field input-kind)) + + (append-map (match-lambda + (((? string? label) (? package? dependency)) + (if (string=? label (package-name dependency)) + '() + (list (warning label (package-name dependency))))) + (((? string? label) (? package? dependency) output) + (let ((expected (string-append (package-name dependency) + ":" output))) + (if (string=? label expected) + '() + (list (warning label expected))))) + (_ + '())) + (package-inputs package))) + + (append-map (match-lambda + ((kind proc) + (check kind proc))) + `((native-inputs ,package-native-inputs) + (inputs ,package-inputs) + (propagated-inputs ,package-propagated-inputs)))) + (define (package-name-regexp package) "Return a regexp that matches PACKAGE's name as a word at the beginning of a line." @@ -1493,6 +1524,10 @@ them for PACKAGE." (name 'inputs-should-not-be-input) (description "Identify inputs that shouldn't be inputs at all") (check check-inputs-should-not-be-an-input-at-all)) + (lint-checker + (name 'input-labels) + (description "Identify input labels that do not match package names") + (check check-input-labels)) (lint-checker (name 'license) ;; TRANSLATORS: is the name of a data type and must not be -- 2.31.1