On 2021-10-22, zimoun wrote: > On Thu, 21 Oct 2021 at 16:18, Vagrant Cascadian <[email protected]> wrote: > >> It has been rewritten to easily add new typo checks, but this one so far >> only addresses pluralized "This packages". Would be easy enough to add >> "allows to" but hard to add a suggested fix... > > If I remember correctly the previous discussion, Debian uses an external > tool for spellchecking. Here, the patch uses a list of “common” > mistakes. It is seems an easy good start. :-)
Yes, I definitely went for "catch some useful things" rather than trying
to be comprehensive... these checks should catch the majority of
historical ones I've noticed, but I didn't bother adding one-off typos.
> Instead, I would use a list of alist ’typo-corrections’ as argument.
> For instance,
>
> --8<---------------cut here---------------start------------->8---
> (define (check-description-typo description typo-corrections)
> (for-each
> (match-lambda
> ((typo . correction)
> (if (string-contains description typo)
> (list
> (make-warning ...))
> '())))
> typo-corrections))
> --8<---------------cut here---------------end--------------->8---
So close! Ludo spotted that the for-each needed to be replaced with
append-map, and that basically did it!
> (check-description-typo description '(("This packages" . "This
> package")))
>
> which allows easily to add new pattern; such as,
>
> '(("This packages" . "This package")
> ("this packages" . "this package")
> ("This modules" . "This module"))
>
> Then, as a second step, depending on the patterns listed, let see if
> there is a pattern inside these patterns. ;-) (Check both capitalize and
> lower-case, etc.)
I haven't seen case issues in practice for these.
I've added "This packages", "This modules", "allows to" and "permits to"
to the list while I was at it. I only added tests for "This packages"
and "allows to" as the others are so similar I'm not sure it's worth
testing...
Here's to hoping for a guix with fewer glaring typos with which to craft
guix poetry. :)
New patch attached!
live well,
vagrant
From a171769da0f737468e06866164eadf1e720764ba Mon Sep 17 00:00:00 2001 From: Vagrant Cascadian <[email protected]> Date: Sun, 24 Oct 2021 04:00:15 -0700 Subject: [PATCH] lint: Add description check for common typos. Fixes: https://issues.guix.gnu.org/44675 * guix/lint.scm (check-description-typo): Add check for occurances of "This packages", "This modules", "allows to" and "permits to" in package descriptions. * tests/lint.scm: Add tests for "This packages" and "allows to". --- guix/lint.scm | 19 +++++++++++++++++++ tests/lint.scm | 14 ++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/guix/lint.scm b/guix/lint.scm index 7b02b9cec0..ac2e7b3841 100644 --- a/guix/lint.scm +++ b/guix/lint.scm @@ -321,6 +321,21 @@ 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-corrections) + "Check that DESCRIPTION does not contain typo, with optional correction" + (append-map + (match-lambda + ((typo . correction) + (if (string-contains description typo) + (list + (make-warning package + (G_ + (format #false + "description contains typo '~a'~@[, should be '~a'~]" + typo correction)))) + '()))) + typo-corrections)) + (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 +416,10 @@ 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") + ("This modules" . "This module") + ("allows to" . #f) + ("permits to" . #f))) ;; 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..6a7eed02e0 100644 --- a/tests/lint.scm +++ b/tests/lint.scm @@ -177,6 +177,20 @@ (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 "description: grammar 'allows to'" + "description contains typo 'allows to'" + (single-lint-warning-message + (let ((pkg (dummy-package "x" + (description "This package allows to do stuff.")))) + (check-description-style pkg)))) + (test-equal "synopsis: not a string" "invalid synopsis: #f" (single-lint-warning-message -- 2.30.2
signature.asc
Description: PGP signature
