diff --git a/guix/lint.scm b/guix/lint.scm index 8f31de041d..ffd3f7007e 100644 --- a/guix/lint.scm +++ b/guix/lint.scm @@ -13,6 +13,7 @@ ;;; Copyright © 2020 Timothy Sample ;;; Copyright © 2021 Xinglu Chen ;;; Copyright © 2021 Maxime Devos +;;; Copyright © 2021 Brice Waegeneire ;;; ;;; This file is part of GNU Guix. ;;; @@ -376,6 +377,15 @@ (define (check-end-of-sentence-space description) 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 @@ (define (check-no-trailing-whitespace description) ;; 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 82971db8f0..0f51b9ef79 100644 --- a/tests/lint.scm +++ b/tests/lint.scm @@ -163,6 +163,13 @@ (define (warning-contains? str warnings) (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