lint: Check for trailing whitespace in synopsis.
authorXinglu Chen <public@yoctocell.xyz>
Sun, 30 May 2021 20:30:31 +0000 (22:30 +0200)
committerLudovic Courtès <ludo@gnu.org>
Tue, 8 Jun 2021 21:28:04 +0000 (23:28 +0200)
* guix/lint.scm (check-synopsis-style): Check for trailing whitespace.
* tests/lint.scm ("synopsis: contains trailing whitespace"): New test.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
guix/lint.scm
tests/lint.scm

index 5cd6db5..1aba9ef 100644 (file)
@@ -478,13 +478,23 @@ markup is valid return a plain-text version of SYNOPSIS, otherwise #f."
                        (G_ "Texinfo markup in synopsis is invalid")
                        #:field 'synopsis)))))
 
+  (define (check-no-trailing-whitespace synopsis)
+    "Check that SYNOPSIS doesn't have trailing whitespace."
+    (if (string-suffix? " " synopsis)
+        (list
+         (make-warning package
+                       (G_ "synopsis contains trailing whitespace")
+                       #:field 'synopsis))
+        '()))
+
   (define checks
     (list check-proper-start
           check-final-period
           check-start-article
           check-start-with-package-name
           check-synopsis-length
-          check-texinfo-markup))
+          check-texinfo-markup
+          check-no-trailing-whitespace))
 
   (match (package-synopsis package)
     (""
index f4c3dde..97ed5ee 100644 (file)
                             (description "Imagine this is Taylor UUCP."))))
     (check-synopsis-style pkg)))
 
+(test-equal "synopsis: contains trailing whitespace"
+  "synopsis contains trailing whitespace"
+  (single-lint-warning-message
+   (let ((pkg (dummy-package "x"
+                             (synopsis "Whitespace "))))
+     (check-synopsis-style pkg))))
+
 (test-equal "name: use underscore in package name"
   "name should use hyphens instead of underscores"
   (single-lint-warning-message