From patchwork Mon Dec 2 22:35:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gabriel Wicki X-Patchwork-Id: 34392 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 6384327BBEA; Mon, 2 Dec 2024 22:36:23 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE, SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id C3C6127BBE2 for ; Mon, 2 Dec 2024 22:36:22 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tIF1Q-0007SB-Ip; Mon, 02 Dec 2024 17:36:04 -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 1tIF1O-0007Rx-5W for guix-patches@gnu.org; Mon, 02 Dec 2024 17:36:02 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tIF1N-0005aH-Ti for guix-patches@gnu.org; Mon, 02 Dec 2024 17:36:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:From:Date:To:In-Reply-To:References:Subject; bh=D0/YAIVUrryEJASRy6SiRxeyNusaFMxZEM+XicmOI/M=; b=NZCxcWOY4sjUEPELHupJZDOkdsGPoadT77ouwEjMj7kJIEyI3hl9McLPMvzzw02MgxIs4Y0rEV1yqG5SKEbAEGJ5tCyxbMSS3NrlJQWQNRqNU/Q75gHBcdsZuYL3DPLlLF/al/oUHtllvmoPuLSbtkxwBz5CfZ6tQ0cJ4TupUp4pSTmnOlHg5+PziCBY68Iwc+O8cDyUsJ9fQPxW0oH6ul+f4RGJFJhrwWb6oARbI8hsbbnKl48HKXiBJxe69Gn1HT14KONZ50e4UWxLnGWODypn89A6dWRkKwHCuf71/HVOjEjNGS6OfHRxqwH918XAJnDUKjUghoN8oyYeCdlNjg==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tIF1N-00041o-OY for guix-patches@gnu.org; Mon, 02 Dec 2024 17:36:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#74459] [PATCH v2 2/7] guix: lint: Refine description start check logic. References: In-Reply-To: Resent-From: Gabriel Wicki Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 02 Dec 2024 22:36:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74459 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 74459@debbugs.gnu.org Received: via spool by 74459-submit@debbugs.gnu.org id=B74459.173317892415414 (code B ref 74459); Mon, 02 Dec 2024 22:36:01 +0000 Received: (at 74459) by debbugs.gnu.org; 2 Dec 2024 22:35:24 +0000 Received: from localhost ([127.0.0.1]:56868 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tIF0m-00040Y-6N for submit@debbugs.gnu.org; Mon, 02 Dec 2024 17:35:24 -0500 Received: from cotopaxi.ee.ethz.ch ([129.132.148.196]:35205) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tIF0j-0003zg-Lj for 74459@debbugs.gnu.org; Mon, 02 Dec 2024 17:35:22 -0500 Received: from localhost (antispam.ee.ethz.ch [129.132.2.16]) by cotopaxi.ee.ethz.ch (Postfix) with ESMTP id 4F6AD1FFFF for <74459@debbugs.gnu.org>; Mon, 2 Dec 2024 23:35:16 +0100 (CET) X-Virus-Scanned: by amavisd at antispam.ee.ethz.ch Received: from cotopaxi.ee.ethz.ch ([129.132.148.196]) by localhost (antispam.ee.ethz.ch [129.132.2.16]) (amavisd-new, port 10028) with ESMTP id HwsZpb35_-mY for <74459@debbugs.gnu.org>; Mon, 2 Dec 2024 23:35:12 +0100 (CET) Received: from blackbox (212-51-128-25.fiber7.init7.net [212.51.128.25]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: gabriel) by cotopaxi.ee.ethz.ch (Postfix) with ESMTPSA for <74459@debbugs.gnu.org>; Mon, 2 Dec 2024 23:35:12 +0100 (CET) Date: Mon, 2 Dec 2024 23:35:09 +0100 From: Gabriel Wicki Message-ID: MIME-Version: 1.0 Content-Disposition: inline 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+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches Fix linter warnings for the following: - packages that belong to some programming language or ecosystem, e.g. python-foo or texlive-bar, - packages whose names end in a version distinction, e.g. wlroots-0.16 and - packages where the software's real name contains an underscore `_' character where our package name replaced that with a hyphen `-', e.g. wpa_supplicant and wpa-supplicant-minimal. * guix/lint.scm (check-description-style)[check-proper-start]: Add conditions. * tests/lint.scm: New tests. Change-Id: Ifc9f5cda04db59e460e287cd93afae89c7f17e3c --- guix/lint.scm | 27 ++++++++++++++++++--------- tests/lint.scm | 25 +++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/guix/lint.scm b/guix/lint.scm index 31d366af46..63d101ebf9 100644 --- a/guix/lint.scm +++ b/guix/lint.scm @@ -14,6 +14,7 @@ ;;; Copyright © 2021 Xinglu Chen ;;; Copyright © 2021-2023 Maxime Devos ;;; Copyright © 2021 Brice Waegeneire +;;; Copyright © 2024 Gabriel Wicki ;;; ;;; This file is part of GNU Guix. ;;; @@ -437,15 +438,23 @@ (define (check-description-style package) '())) (define (check-proper-start description) - (if (or (string-null? description) - (properly-starts-sentence? description) - (string-prefix-ci? (package-name package) description)) - '() - (list - (make-warning - package - (G_ "description should start with an upper-case letter or digit") - #:field 'description)))) + (let* ((initial + (string-take description + (or (string-index description #\space) + 0))) + (first-word + (regexp-substitute/global #f "_" initial + 'pre "-" 'post))) + (if (or (string-null? description) + (properly-starts-sentence? description) + (string-prefix-ci? first-word (package-name package)) + (string-suffix-ci? first-word (package-name package))) + '() + (list + (make-warning + package + (G_ "description should start with an upper-case letter or digit") + #:field 'description))))) (define (check-end-of-sentence-space description) "Check that an end-of-sentence period is followed by two spaces." diff --git a/tests/lint.scm b/tests/lint.scm index b899ebc700..9297bfbaac 100644 --- a/tests/lint.scm +++ b/tests/lint.scm @@ -11,6 +11,7 @@ ;;; Copyright © 2020 Tobias Geerinckx-Rice ;;; Copyright © 2021 Xinglu Chen ;;; Copyright © 2021, 2023 Maxime Devos +;;; Copyright © 2024 Gabriel Wicki ;;; ;;; This file is part of GNU Guix. ;;; @@ -132,6 +133,30 @@ (define (warning-contains? str warnings) (description "x is a dummy package.")))) (check-description-style pkg))) +(test-equal "description: may start with beginning of package name" + '() + (let ((pkg (dummy-package "xyz-0.1" + (description "xyz is a dummy package.")))) + (check-description-style pkg))) + +(test-equal "description: may start with end of package name" + '() + (let ((pkg (dummy-package "foobar-xyz" + (description "xyz is a dummy package.")))) + (check-description-style pkg))) + +(test-equal "description: may start with non-hyphenated package name" + '() + (let ((pkg (dummy-package "foobar-xyz-minimal" + (description "foobar_xyz is a dummy package.")))) + (check-description-style pkg))) + +(test-equal "description: may start with end of package name" + '() + (let ((pkg (dummy-package "foo-bar" + (description "bar is some thing in foo.")))) + (check-description-style pkg))) + (test-equal "description: two spaces after end of sentence" "sentences in description should be followed by two spaces; possible infraction at 3" (single-lint-warning-message