guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

04/04: lint: Check for leading whitespace in description.


From: guix-commits
Subject: 04/04: lint: Check for leading whitespace in description.
Date: Tue, 13 Jul 2021 01:25:38 -0400 (EDT)

bricewge pushed a commit to branch master
in repository guix.

commit edb328ad83bf55e021018719d24f7c29adc43a96
Author: Brice Waegeneire <brice@waegenei.re>
AuthorDate: Sat Jun 19 21:59:48 2021 +0200

    lint: Check for leading whitespace in description.
    
    * 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 8f31de0..ffd3f70 100644
--- a/guix/lint.scm
+++ b/guix/lint.scm
@@ -13,6 +13,7 @@
 ;;; Copyright © 2020 Timothy Sample <samplet@ngyro.com>
 ;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
 ;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
+;;; Copyright © 2021 Brice Waegeneire <brice@waegenei.re>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -376,6 +377,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)
@@ -394,6 +404,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 82971db..0f51b9e 100644
--- a/tests/lint.scm
+++ b/tests/lint.scm
@@ -163,6 +163,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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]