guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#74459] [PATCH 2/8] guix: lint: Refine description start check logic


From: Ludovic Courtès
Subject: [bug#74459] [PATCH 2/8] guix: lint: Refine description start check logic.
Date: Fri, 29 Nov 2024 14:54:00 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

Hi,

Gabriel Wicki <gabriel@erlikon.ch> skribis:

> Fix linter warnings for the following:
>
>  - packages that belong to some programming language or ecosystem,
>  e.g. python-foo or texlive-bar,
>  - packages whose names end in a version distinction, e.g. wlroots-0.16 and
>  - packages where the software's real name contains an underscore `_'
>  character where our package name replaced that with a hyphen `-',
>  e.g. wpa_supplicant and wpa-supplicant-minimal.
>
> * guix/lint.scm (check-description-style)[check-proper-start]: Add conditions.
> * tests/lint.scm: New tests.
>
> Change-Id: Ifc9f5cda04db59e460e287cd93afae89c7f17e3c

[...]

>    (define (check-proper-start description)
> -    (if (or (string-null? description)
> -            (properly-starts-sentence? description)
> -            (string-prefix-ci? (package-name package) description))
> -        '()
> -        (list
> -         (make-warning
> -          package
> -          (G_ "description should start with an upper-case letter or digit")
> -          #:field 'description))))
> +    (let* ((initial (car (string-split description #\space)))

In general we try to avoid ‘car’ and ‘cdr’:

  
https://guix.gnu.org/manual/devel/en/html_node/Data-Types-and-Pattern-Matching.html

But also, instead of traversing all of ‘description’, perhaps you could
have something like (untested):

  (define (first-word str)
    (let* ((str (string-trim str))
           (length (or (and=> (string-index str #\space) 1+) (string-length 
str))))
      (string-take str length)))

Ludo’.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]