From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id sHz6BQPZ3GBWZAEAgWs5BA (envelope-from ) for ; Wed, 30 Jun 2021 22:50:11 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id AKquAQPZ3GBOPAAAB5/wlQ (envelope-from ) for ; Wed, 30 Jun 2021 20:50:11 +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 C4C87221CF for ; Wed, 30 Jun 2021 22:50:10 +0200 (CEST) Received: from localhost ([::1]:53200 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lyh9t-0000qL-OQ for larch@yhetil.org; Wed, 30 Jun 2021 16:50:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45896) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lyh9n-0000pw-8z for guix-patches@gnu.org; Wed, 30 Jun 2021 16:50:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:47408) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lyh9n-0001g9-23 for guix-patches@gnu.org; Wed, 30 Jun 2021 16:50:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lyh9n-0005Bx-0B for guix-patches@gnu.org; Wed, 30 Jun 2021 16:50:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49169] [PATCH v2 03/16] lint: Add 'input-labels' checker. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 30 Jun 2021 20:50:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49169 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 49169@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 49169-submit@debbugs.gnu.org id=B49169.162508615119781 (code B ref 49169); Wed, 30 Jun 2021 20:50:02 +0000 Received: (at 49169) by debbugs.gnu.org; 30 Jun 2021 20:49:11 +0000 Received: from localhost ([127.0.0.1]:58926 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lyh8x-00058v-Cb for submit@debbugs.gnu.org; Wed, 30 Jun 2021 16:49:11 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47864) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lyh8k-00055j-4B for 49169@debbugs.gnu.org; Wed, 30 Jun 2021 16:48:58 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:53124) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lyh8e-0000wL-Sj; Wed, 30 Jun 2021 16:48:52 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=42586 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 1lyh8e-0001jQ-Ki; Wed, 30 Jun 2021 16:48:52 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Wed, 30 Jun 2021 22:48:19 +0200 Message-Id: <20210630204832.25753-4-ludo@gnu.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210630204832.25753-1-ludo@gnu.org> References: <20210622090221.15182-1-ludo@gnu.org> <20210630204832.25753-1-ludo@gnu.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1625086210; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=yGKJOBsgYbDC9VmyQ5zrWW09iiSDztQW38CiZW1x5/E=; b=Dy9UcRuglpV7oRbzVzbLKb5RSB+lH0h73MN1BYbLGNHTkXsxa5eg/F7uqrrRuLyPs+BAuk K2Bzdy91qpj8ramC6CoVIJZesXH9ZnHTexHT5StP+cmBq4jQaHm938wVbC64cw9nK3MIIu Yp/zHC9D3FBwUZ3FVowYpdDh3zDWN1wOBoa1Gcryv6G5mmOPBoOx8U+YbBh94i39dQT0WW 3EZ+FmcdHLYHOvxS8tJgtAu6BJ9rYgvh3mr+kcePWJjoj5CaiFxQMwoLH6zHWLeEak30CX uLJvc/SyrpJNNYHl/0W0VN2RpVuQsikytjCd+P1eIys6YD5tfqVQ7sdBGWQEtQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1625086210; a=rsa-sha256; cv=none; b=mcmPvg57oMaUzQp11KpPdeCJOdLAuMMysCfcqwjQqbzujTxWBs0jIanIJiJO0EROA91t2K 0S1d09krbKUgY5lpFnW6HeIN/73qq9Jv63c3FX+rsk9oXCzVoi0c6c8dHAVImcHqWL715i APlELBJ1m8oOSo9Iy4tahxJawyg/2nP2YozJqjTJhe1GSQdJ8+2kKYzgrIwPMbSAq+leNP zJvwid1PzswESh7KXwnLeRjB0/Y6L+QJeYgwFqUpnCw5x2YzHFe9uPQLOmOQAO+c7bB0mo qtYamF7IQ0AOzJWCu8zkhOhtGU2P0jX1WYRMN2152o+HT7kOrNfqGTJNww0T/Q== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; 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-Migadu-Spam-Score: 3.58 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; 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-Migadu-Queue-Id: C4C87221CF X-Spam-Score: 3.58 X-Migadu-Scanner: scn0.migadu.com X-TUID: rF9V+l8uTOfi * guix/lint.scm (check-input-labels): New procedure. (%local-checkers): Add 'input-labels' checker. * tests/lint.scm ("input labels: no warnings") ("input labels: one warning"): New tests. * doc/guix.texi (Invoking guix lint): Mention it. --- doc/guix.texi | 6 ++++++ guix/lint.scm | 36 ++++++++++++++++++++++++++++++++++++ tests/lint.scm | 14 ++++++++++++++ 3 files changed, 56 insertions(+) diff --git a/doc/guix.texi b/doc/guix.texi index 1659a2687a..0e5d1a9fa7 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -12153,6 +12153,12 @@ declare them as in this example: @item formatting Warn about obvious source code formatting issues: trailing white space, use of tabulations, etc. + +@item input-labels +Report old-style input labels that do not match the name of the +corresponding package. This aims to help migrate from the ``old input +style''. @xref{package Reference}, for more information on package +inputs and input styles. @end table The general syntax is: diff --git a/guix/lint.scm b/guix/lint.scm index d65d5ce8f9..198e091f47 100644 --- a/guix/lint.scm +++ b/guix/lint.scm @@ -79,6 +79,7 @@ #:export (check-description-style check-inputs-should-be-native check-inputs-should-not-be-an-input-at-all + check-input-labels check-patch-file-names check-patch-headers check-synopsis-style @@ -416,6 +417,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." @@ -1583,6 +1615,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 diff --git a/tests/lint.scm b/tests/lint.scm index 6222c3b15a..0a8f1c6f54 100644 --- a/tests/lint.scm +++ b/tests/lint.scm @@ -356,6 +356,20 @@ `(("python-setuptools" ,python-setuptools)))))) (check-inputs-should-not-be-an-input-at-all pkg)))) +(test-assert "input labels: no warnings" + (let ((pkg (dummy-package "x" + (inputs `(("glib" ,glib) + ("pkg-config" ,pkg-config)))))) + (null? (check-input-labels pkg)))) + +(test-equal "input labels: one warning" + "label 'pkgkonfig' does not match package name 'pkg-config'" + (single-lint-warning-message + (let ((pkg (dummy-package "x" + (inputs `(("glib" ,glib) + ("pkgkonfig" ,pkg-config)))))) + (check-input-labels pkg)))) + (test-equal "file patches: different file name -> warning" "file names of patches should start with the package name" (single-lint-warning-message -- 2.32.0