From: Gabriel Wicki <gabriel@erlikon.ch>
To: 74459@debbugs.gnu.org
Subject: [bug#74459] [PATCH v2 2/7] guix: lint: Refine description start check logic.
Date: Mon, 2 Dec 2024 23:35:09 +0100 [thread overview]
Message-ID: <m4upzdd34ue3oxpydpt65yaah2r66zfflwzt62byzbuiqxkv5o@iu5ocslqhrop> (raw)
In-Reply-To: <po7r7oijub2gkqzxwkgm76cprdnm3yvy4lsnwjbl4tven5zkxy@riur6kp7ldps>
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
---
guix/lint.scm | 27 ++++++++++++++++++---------
tests/lint.scm | 25 +++++++++++++++++++++++++
2 files changed, 43 insertions(+), 9 deletions(-)
diff --git a/guix/lint.scm b/guix/lint.scm
index 31d366af46..63d101ebf9 100644
--- a/guix/lint.scm
+++ b/guix/lint.scm
@@ -14,6 +14,7 @@
;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
;;; Copyright © 2021-2023 Maxime Devos <maximedevos@telenet.be>
;;; Copyright © 2021 Brice Waegeneire <brice@waegenei.re>
+;;; Copyright © 2024 Gabriel Wicki <gabriel@erlikon.ch>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -437,15 +438,23 @@ (define (check-description-style package)
'()))
(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
+ (string-take description
+ (or (string-index description #\space)
+ 0)))
+ (first-word
+ (regexp-substitute/global #f "_" initial
+ 'pre "-" 'post)))
+ (if (or (string-null? description)
+ (properly-starts-sentence? description)
+ (string-prefix-ci? first-word (package-name package))
+ (string-suffix-ci? first-word (package-name package)))
+ '()
+ (list
+ (make-warning
+ package
+ (G_ "description should start with an upper-case letter or digit")
+ #:field 'description)))))
(define (check-end-of-sentence-space description)
"Check that an end-of-sentence period is followed by two spaces."
diff --git a/tests/lint.scm b/tests/lint.scm
index b899ebc700..9297bfbaac 100644
--- a/tests/lint.scm
+++ b/tests/lint.scm
@@ -11,6 +11,7 @@
;;; Copyright © 2020 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
;;; Copyright © 2021, 2023 Maxime Devos <maximedevos@telenet.be>
+;;; Copyright © 2024 Gabriel Wicki <gabriel@erlikon.ch>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -132,6 +133,30 @@ (define (warning-contains? str warnings)
(description "x is a dummy package."))))
(check-description-style pkg)))
+(test-equal "description: may start with beginning of package name"
+ '()
+ (let ((pkg (dummy-package "xyz-0.1"
+ (description "xyz is a dummy package."))))
+ (check-description-style pkg)))
+
+(test-equal "description: may start with end of package name"
+ '()
+ (let ((pkg (dummy-package "foobar-xyz"
+ (description "xyz is a dummy package."))))
+ (check-description-style pkg)))
+
+(test-equal "description: may start with non-hyphenated package name"
+ '()
+ (let ((pkg (dummy-package "foobar-xyz-minimal"
+ (description "foobar_xyz is a dummy package."))))
+ (check-description-style pkg)))
+
+(test-equal "description: may start with end of package name"
+ '()
+ (let ((pkg (dummy-package "foo-bar"
+ (description "bar is some thing in foo."))))
+ (check-description-style pkg)))
+
(test-equal "description: two spaces after end of sentence"
"sentences in description should be followed by two spaces; possible infraction at 3"
(single-lint-warning-message
--
2.46.0
next prev parent reply other threads:[~2024-12-02 22:36 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-21 12:40 [bug#74459] [PATCH 0/8] Linter improvements (eliminate false positives)^[ Gabriel Wicki
2024-11-21 12:43 ` [bug#74459] [PATCH 1/8] guix: lint: Fix indentation Gabriel Wicki
2024-11-21 12:44 ` [bug#74459] [PATCH 2/8] guix: lint: Refine description start check logic Gabriel Wicki
2024-11-29 13:54 ` Ludovic Courtès
2024-11-21 12:45 ` [bug#74459] [PATCH 3/8] guix: lint: Allow texinfo markup at beginning of description Gabriel Wicki
2024-11-21 12:46 ` [bug#74459] [PATCH 4/8] guix: lint: Allow texinfo markup at beginning of synopsis Gabriel Wicki
2024-11-21 12:47 ` [bug#74459] [PATCH 5/8] guix: lint: Prevent false positives in description typo check Gabriel Wicki
2024-11-21 12:48 ` [bug#74459] [PATCH 6/8] guix: lint: Ignore initials from double space check Gabriel Wicki
2024-11-21 12:49 ` [bug#74459] [PATCH 7/8] guix: lint: More abbreviations Gabriel Wicki
2024-11-21 22:25 ` [bug#74459] comments Gabriel Wicki
2024-11-29 13:55 ` Ludovic Courtès
2024-12-02 22:34 ` [bug#74459] [PATCH v2 1/7] guix: lint: Fix indentation Gabriel Wicki
2024-12-02 22:46 ` [bug#74459] comments Gabriel Wicki
2024-12-02 22:35 ` Gabriel Wicki [this message]
2024-12-02 22:36 ` [bug#74459] [PATCH v2 3/7] guix: lint: Allow texinfo markup at beginning of description Gabriel Wicki
2024-12-02 22:37 ` [bug#74459] [PATCH v2 4/7] guix: lint: Allow texinfo markup at beginning of synopsis Gabriel Wicki
2024-12-02 22:38 ` [bug#74459] [PATCH v2 5/7] guix: lint: Prevent false positives in description typo check Gabriel Wicki
2024-12-02 22:39 ` [bug#74459] [PATCH v2 6/7] guix: lint: Ignore initials from double space check Gabriel Wicki
2024-12-02 22:40 ` [bug#74459] [PATCH v2 7/7] guix: lint: More abbreviations Gabriel Wicki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m4upzdd34ue3oxpydpt65yaah2r66zfflwzt62byzbuiqxkv5o@iu5ocslqhrop \
--to=gabriel@erlikon.ch \
--cc=74459@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.