diff options
| author | Brice Waegeneire <brice@waegenei.re> | 2021-06-19 21:59:48 +0200 |
|---|---|---|
| committer | Brice Waegeneire <brice@waegenei.re> | 2021-07-13 07:25:05 +0200 |
| commit | edb328ad83bf55e021018719d24f7c29adc43a96 (patch) | |
| tree | f735127984e933e6648b278d963bb72aeea15265 | |
| parent | a5fa05dfc7e5bbe0191938b7824ec264aa842306 (diff) | |
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.
| -rw-r--r-- | guix/lint.scm | 11 | ||||
| -rw-r--r-- | tests/lint.scm | 7 |
2 files changed, 18 insertions, 0 deletions
diff --git a/guix/lint.scm b/guix/lint.scm index 8f31de041dd..ffd3f7007e7 100644 --- a/guix/lint.scm +++ b/guix/lint.scm | |||
| @@ -13,6 +13,7 @@ | |||
| 13 | ;;; Copyright © 2020 Timothy Sample <samplet@ngyro.com> | 13 | ;;; Copyright © 2020 Timothy Sample <samplet@ngyro.com> |
| 14 | ;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz> | 14 | ;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz> |
| 15 | ;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be> | 15 | ;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be> |
| 16 | ;;; Copyright © 2021 Brice Waegeneire <brice@waegenei.re> | ||
| 16 | ;;; | 17 | ;;; |
| 17 | ;;; This file is part of GNU Guix. | 18 | ;;; This file is part of GNU Guix. |
| 18 | ;;; | 19 | ;;; |
| @@ -376,6 +377,15 @@ by two spaces; possible infraction~p at ~{~a~^, ~}") | |||
| 376 | infractions) | 377 | infractions) |
| 377 | #:field 'description))))) | 378 | #:field 'description))))) |
| 378 | 379 | ||
| 380 | (define (check-no-leading-whitespace description) | ||
| 381 | "Check that DESCRIPTION doesn't have trailing whitespace." | ||
| 382 | (if (string-prefix? " " description) | ||
| 383 | (list | ||
| 384 | (make-warning package | ||
| 385 | (G_ "description contains leading whitespace") | ||
| 386 | #:field 'description)) | ||
| 387 | '())) | ||
| 388 | |||
| 379 | (define (check-no-trailing-whitespace description) | 389 | (define (check-no-trailing-whitespace description) |
| 380 | "Check that DESCRIPTION doesn't have trailing whitespace." | 390 | "Check that DESCRIPTION doesn't have trailing whitespace." |
| 381 | (if (string-suffix? " " description) | 391 | (if (string-suffix? " " description) |
| @@ -394,6 +404,7 @@ by two spaces; possible infraction~p at ~{~a~^, ~}") | |||
| 394 | ;; Use raw description for this because Texinfo rendering | 404 | ;; Use raw description for this because Texinfo rendering |
| 395 | ;; automatically fixes end of sentence space. | 405 | ;; automatically fixes end of sentence space. |
| 396 | (check-end-of-sentence-space description) | 406 | (check-end-of-sentence-space description) |
| 407 | (check-no-leading-whitespace description) | ||
| 397 | (check-no-trailing-whitespace description) | 408 | (check-no-trailing-whitespace description) |
| 398 | (match (check-texinfo-markup description) | 409 | (match (check-texinfo-markup description) |
| 399 | ((and warning (? lint-warning?)) (list warning)) | 410 | ((and warning (? lint-warning?)) (list warning)) |
diff --git a/tests/lint.scm b/tests/lint.scm index 82971db8f00..0f51b9ef792 100644 --- a/tests/lint.scm +++ b/tests/lint.scm | |||
| @@ -163,6 +163,13 @@ | |||
| 163 | (description "This is a 'quoted' thing.")))) | 163 | (description "This is a 'quoted' thing.")))) |
| 164 | (check-description-style pkg)))) | 164 | (check-description-style pkg)))) |
| 165 | 165 | ||
| 166 | (test-equal "description: leading whitespace" | ||
| 167 | "description contains leading whitespace" | ||
| 168 | (single-lint-warning-message | ||
| 169 | (let ((pkg (dummy-package "x" | ||
| 170 | (description " Whitespace.")))) | ||
| 171 | (check-description-style pkg)))) | ||
| 172 | |||
| 166 | (test-equal "description: trailing whitespace" | 173 | (test-equal "description: trailing whitespace" |
| 167 | "description contains trailing whitespace" | 174 | "description contains trailing whitespace" |
| 168 | (single-lint-warning-message | 175 | (single-lint-warning-message |
