mirror of
https://git.savannah.gnu.org/git/guix.git
synced 2025-02-07 11:29:59 +01:00
lint: Check for leading whitespace in description.
* guix/lint.scm (check-description-style): Check for leading whitespace. * tests/lint.scm: ("description: leading whitespace"): New test.
This commit is contained in:
parent
a5fa05dfc7
commit
edb328ad83
2 changed files with 18 additions and 0 deletions
|
@ -13,6 +13,7 @@
|
||||||
;;; Copyright © 2020 Timothy Sample <samplet@ngyro.com>
|
;;; Copyright © 2020 Timothy Sample <samplet@ngyro.com>
|
||||||
;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
|
;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
|
||||||
;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
|
;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
|
||||||
|
;;; Copyright © 2021 Brice Waegeneire <brice@waegenei.re>
|
||||||
;;;
|
;;;
|
||||||
;;; This file is part of GNU Guix.
|
;;; This file is part of GNU Guix.
|
||||||
;;;
|
;;;
|
||||||
|
@ -376,6 +377,15 @@ by two spaces; possible infraction~p at ~{~a~^, ~}")
|
||||||
infractions)
|
infractions)
|
||||||
#:field 'description)))))
|
#: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)
|
(define (check-no-trailing-whitespace description)
|
||||||
"Check that DESCRIPTION doesn't have trailing whitespace."
|
"Check that DESCRIPTION doesn't have trailing whitespace."
|
||||||
(if (string-suffix? " " description)
|
(if (string-suffix? " " description)
|
||||||
|
@ -394,6 +404,7 @@ by two spaces; possible infraction~p at ~{~a~^, ~}")
|
||||||
;; Use raw description for this because Texinfo rendering
|
;; Use raw description for this because Texinfo rendering
|
||||||
;; automatically fixes end of sentence space.
|
;; automatically fixes end of sentence space.
|
||||||
(check-end-of-sentence-space description)
|
(check-end-of-sentence-space description)
|
||||||
|
(check-no-leading-whitespace description)
|
||||||
(check-no-trailing-whitespace description)
|
(check-no-trailing-whitespace description)
|
||||||
(match (check-texinfo-markup description)
|
(match (check-texinfo-markup description)
|
||||||
((and warning (? lint-warning?)) (list warning))
|
((and warning (? lint-warning?)) (list warning))
|
||||||
|
|
|
@ -163,6 +163,13 @@
|
||||||
(description "This is a 'quoted' thing."))))
|
(description "This is a 'quoted' thing."))))
|
||||||
(check-description-style pkg))))
|
(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"
|
(test-equal "description: trailing whitespace"
|
||||||
"description contains trailing whitespace"
|
"description contains trailing whitespace"
|
||||||
(single-lint-warning-message
|
(single-lint-warning-message
|
||||||
|
|
Loading…
Add table
Reference in a new issue