lint: Check for trailing whitespace in synopsis.

* 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>
This commit is contained in:
Xinglu Chen 2021-05-30 22:30:31 +02:00 committed by Ludovic Courtès
parent 9178566954
commit 04afb76958
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5
2 changed files with 18 additions and 1 deletions

View file

@ -478,13 +478,23 @@ (define (check-texinfo-markup synopsis)
(G_ "Texinfo markup in synopsis is invalid") (G_ "Texinfo markup in synopsis is invalid")
#:field 'synopsis))))) #: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 (define checks
(list check-proper-start (list check-proper-start
check-final-period check-final-period
check-start-article check-start-article
check-start-with-package-name check-start-with-package-name
check-synopsis-length check-synopsis-length
check-texinfo-markup)) check-texinfo-markup
check-no-trailing-whitespace))
(match (package-synopsis package) (match (package-synopsis package)
("" (""

View file

@ -271,6 +271,13 @@ (define (warning-contains? str warnings)
(description "Imagine this is Taylor UUCP.")))) (description "Imagine this is Taylor UUCP."))))
(check-synopsis-style pkg))) (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" (test-equal "name: use underscore in package name"
"name should use hyphens instead of underscores" "name should use hyphens instead of underscores"
(single-lint-warning-message (single-lint-warning-message