diff mbox series

[bug#48750,1/2] lint: Check for trailing whitespace in synopsis.

Message ID 2263996fdbd5853d7c16ea5fade00f1e1c0a448d.1622406578.git.public@yoctocell.xyz
State Accepted
Headers show
Series [bug#48750,1/2] lint: Check for trailing whitespace in synopsis. | expand

Commit Message

Xinglu Chen May 30, 2021, 8:30 p.m. UTC
* guix/lint.scm (check-synopsis-style): Check for trailing whitespace.
* tests/lint.scm ("synopsis: contains trailing whitespace"): New test.
---
 guix/lint.scm  | 12 +++++++++++-
 tests/lint.scm |  7 +++++++
 2 files changed, 18 insertions(+), 1 deletion(-)


base-commit: cefa260fb42693b87545b1baab8cef9723827f80
diff mbox series

Patch

diff --git a/guix/lint.scm b/guix/lint.scm
index a2d6418b85..d2ef4f34b2 100644
--- a/guix/lint.scm
+++ b/guix/lint.scm
@@ -456,13 +456,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)
     (""
diff --git a/tests/lint.scm b/tests/lint.scm
index d54fafc1d2..dddbf0679f 100644
--- a/tests/lint.scm
+++ b/tests/lint.scm
@@ -271,6 +271,13 @@ 
                             (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