From patchwork Sun Jun 20 13:34:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Brice Waegeneire X-Patchwork-Id: 30545 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 4ACE327BC81; Sun, 20 Jun 2021 14:35:24 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 0759327BC78 for ; Sun, 20 Jun 2021 14:35:24 +0100 (BST) Received: from localhost ([::1]:55906 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luxbe-0003q3-Ss for patchwork@mira.cbaines.net; Sun, 20 Jun 2021 09:35:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38546) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luxbL-0003o4-2r for guix-patches@gnu.org; Sun, 20 Jun 2021 09:35:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:49935) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luxbK-0005Ab-PP for guix-patches@gnu.org; Sun, 20 Jun 2021 09:35:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1luxbK-0004Ff-G5 for guix-patches@gnu.org; Sun, 20 Jun 2021 09:35:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49133] [PATCH] lint: Check for leading whitespace in description. Resent-From: Brice Waegeneire Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 20 Jun 2021 13:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 49133 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 49133@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.162419607116299 (code B ref -1); Sun, 20 Jun 2021 13:35:02 +0000 Received: (at submit) by debbugs.gnu.org; 20 Jun 2021 13:34:31 +0000 Received: from localhost ([127.0.0.1]:33248 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1luxap-0004Ep-Hx for submit@debbugs.gnu.org; Sun, 20 Jun 2021 09:34:31 -0400 Received: from lists.gnu.org ([209.51.188.17]:42570) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1luxan-0004Eh-4x for submit@debbugs.gnu.org; Sun, 20 Jun 2021 09:34:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38418) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luxam-0003Fk-Ll for guix-patches@gnu.org; Sun, 20 Jun 2021 09:34:28 -0400 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:44247) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luxaj-0004wV-Md for guix-patches@gnu.org; Sun, 20 Jun 2021 09:34:28 -0400 Received: (Authenticated sender: brice@waegenei.re) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 8CB41240003 for ; Sun, 20 Jun 2021 13:34:21 +0000 (UTC) From: Brice Waegeneire Date: Sun, 20 Jun 2021 15:34:19 +0200 Message-Id: <20210620133419.15883-1-brice@waegenei.re> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Received-SPF: pass client-ip=217.70.183.193; envelope-from=brice@waegenei.re; helo=relay1-d.mail.gandi.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * guix/lint.scm (check-description-style): Check for leading whitespace. * tests/lint.scm: ("description: leading whitespace"): New test. --- guix/lint.scm | 11 +++++++++++ tests/lint.scm | 7 +++++++ 2 files changed, 18 insertions(+) diff --git a/guix/lint.scm b/guix/lint.scm index d65d5ce8f9..d18fcf920e 100644 --- a/guix/lint.scm +++ b/guix/lint.scm @@ -13,6 +13,7 @@ ;;; Copyright © 2020 Timothy Sample ;;; Copyright © 2021 Xinglu Chen ;;; Copyright © 2021 Maxime Devos +;;; Copyright © 2021 Brice Waegeneire ;;; ;;; This file is part of GNU Guix. ;;; @@ -300,6 +301,15 @@ by two spaces; possible infraction~p at ~{~a~^, ~}") infractions) #:field 'description))))) + (define (check-no-leading-whitespace description) + "Check that DESCRIPTION doesn't have trailing whitespace." + (if (string-prefix? " " description) + (list + (make-warning package + (G_ "description contains leading whitespace") + #:field 'description)) + '())) + (define (check-no-trailing-whitespace description) "Check that DESCRIPTION doesn't have trailing whitespace." (if (string-suffix? " " description) @@ -318,6 +328,7 @@ by two spaces; possible infraction~p at ~{~a~^, ~}") ;; Use raw description for this because Texinfo rendering ;; automatically fixes end of sentence space. (check-end-of-sentence-space description) + (check-no-leading-whitespace description) (check-no-trailing-whitespace description) (match (check-texinfo-markup description) ((and warning (? lint-warning?)) (list warning)) diff --git a/tests/lint.scm b/tests/lint.scm index fae346e724..dd442f6af9 100644 --- a/tests/lint.scm +++ b/tests/lint.scm @@ -160,6 +160,13 @@ (description "This is a 'quoted' thing.")))) (check-description-style pkg)))) +(test-equal "description: leading whitespace" + "description contains leading whitespace" + (single-lint-warning-message + (let ((pkg (dummy-package "x" + (description " Whitespace.")))) + (check-description-style pkg)))) + (test-equal "description: trailing whitespace" "description contains trailing whitespace" (single-lint-warning-message