From 3ab46ca7932614ab4c699512c2fbfa8207ffa964 Mon Sep 17 00:00:00 2001 From: Vagrant Cascadian Date: Thu, 21 Oct 2021 15:51:11 -0700 Subject: [PATCH] lint: Add description check for pluralized "This package" Partial fix for: https://issues.guix.gnu.org/44675 * guix/lint.scm (check-description-typo): Add check for occurances of "This packages" in package descriptions. * tests/lint.scm: Add test. --- guix/lint.scm | 12 ++++++++++++ tests/lint.scm | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/guix/lint.scm b/guix/lint.scm index 7b02b9cec0..b22454fd31 100644 --- a/guix/lint.scm +++ b/guix/lint.scm @@ -321,6 +321,17 @@ markup is valid return a plain-text version of DESCRIPTION, otherwise #f." (G_ "Texinfo markup in description is invalid") #:field 'description)))) + (define (check-description-typo description typo correction) + "Check that DESCRIPTION does not contain typo, with optional correction" + (if (string-contains description typo) + (list + (make-warning package + (G_ + (format #false + "description contains typo '~a'~@[, should be '~a'~]" + typo correction)))) + '())) + (define (check-trademarks description) "Check that DESCRIPTION does not contain '™' or '®' characters. See http://www.gnu.org/prep/standards/html_node/Trademarks.html." @@ -401,6 +412,7 @@ by two spaces; possible infraction~p at ~{~a~^, ~}") (check-not-empty description) (check-quotes description) (check-trademarks description) + (check-description-typo description "This packages" "This package") ;; Use raw description for this because Texinfo rendering ;; automatically fixes end of sentence space. (check-end-of-sentence-space description) diff --git a/tests/lint.scm b/tests/lint.scm index 699a750eb9..1902a87354 100644 --- a/tests/lint.scm +++ b/tests/lint.scm @@ -177,6 +177,13 @@ (description "Whitespace. ")))) (check-description-style pkg)))) +(test-equal "description: pluralized 'This package'" + "description contains typo 'This packages', should be 'This package'" + (single-lint-warning-message + (let ((pkg (dummy-package "x" + (description "This packages is a typo.")))) + (check-description-style pkg)))) + (test-equal "synopsis: not a string" "invalid synopsis: #f" (single-lint-warning-message -- 2.30.2