[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
04/04: lint: Check for trailing whitespace in description.
From: |
guix-commits |
Subject: |
04/04: lint: Check for trailing whitespace in description. |
Date: |
Tue, 8 Jun 2021 17:29:04 -0400 (EDT) |
civodul pushed a commit to branch master
in repository guix.
commit 93d85deae6bce16bc21fb42ad6a68a1bcbb72527
Author: Xinglu Chen <public@yoctocell.xyz>
AuthorDate: Sun May 30 22:30:32 2021 +0200
lint: Check for trailing whitespace in description.
* guix/lint.scm (check-description-style): Check for trailing whitespace.
* tests/lint.scm: ("description: trailing whitespace"): New test.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
---
guix/lint.scm | 10 ++++++++++
tests/lint.scm | 7 +++++++
2 files changed, 17 insertions(+)
diff --git a/guix/lint.scm b/guix/lint.scm
index 1aba9ef..8115f2a 100644
--- a/guix/lint.scm
+++ b/guix/lint.scm
@@ -300,6 +300,15 @@ by two spaces; possible infraction~p at ~{~a~^, ~}")
infractions)
#:field 'description)))))
+ (define (check-no-trailing-whitespace description)
+ "Check that DESCRIPTION doesn't have trailing whitespace."
+ (if (string-suffix? " " description)
+ (list
+ (make-warning package
+ (G_ "description contains trailing whitespace")
+ #:field 'description))
+ '()))
+
(let ((description (package-description package)))
(if (string? description)
(append
@@ -309,6 +318,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-trailing-whitespace description)
(match (check-texinfo-markup description)
((and warning (? lint-warning?)) (list warning))
(plain-description
diff --git a/tests/lint.scm b/tests/lint.scm
index 97ed5ee..fae346e 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: trailing whitespace"
+ "description contains trailing whitespace"
+ (single-lint-warning-message
+ (let ((pkg (dummy-package "x"
+ (description "Whitespace. "))))
+ (check-description-style pkg))))
+
(test-equal "synopsis: not a string"
"invalid synopsis: #f"
(single-lint-warning-message