[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
04/15: lint: Refine description start check logic.
From: |
guix-commits |
Subject: |
04/15: lint: Refine description start check logic. |
Date: |
Thu, 12 Dec 2024 06:54:24 -0500 (EST) |
civodul pushed a commit to branch master
in repository guix.
commit 00879f94eeadb63f17278ff2f5acb666f6879d22
Author: Gabriel Wicki <gabriel@erlikon.ch>
AuthorDate: Mon Dec 2 23:35:09 2024 +0100
lint: Refine description start check logic.
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
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
---
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 @@ trademark sign '~a' at ~d")
'()))
(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 @@
(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
- branch master updated (d916d3b156 -> 9ef5533123), guix-commits, 2024/12/12
- 01/15: transformations: Add tuning wrapper for gfortran., guix-commits, 2024/12/12
- 03/15: lint: Fix indentation., guix-commits, 2024/12/12
- 07/15: lint: Prevent false positives in description typo check., guix-commits, 2024/12/12
- 08/15: lint: Ignore initials from double space check., guix-commits, 2024/12/12
- 09/15: lint: More abbreviations., guix-commits, 2024/12/12
- 10/15: lint: Pre-compile regexp for ‘starts-with-texinfo-markup?’., guix-commits, 2024/12/12
- 11/15: services: cuirass: Run in a UTF-8 locale., guix-commits, 2024/12/12
- 04/15: lint: Refine description start check logic.,
guix-commits <=
- 02/15: gnu: lapack: Mark as tunable., guix-commits, 2024/12/12
- 05/15: lint: Allow texinfo markup at beginning of description., guix-commits, 2024/12/12
- 06/15: lint: Allow texinfo markup at beginning of synopsis., guix-commits, 2024/12/12
- 12/15: remote: Do not double-quote the repl-command., guix-commits, 2024/12/12
- 14/15: gnu: hyprutils: Fix cross-compilation., guix-commits, 2024/12/12
- 13/15: doc: cookbook: Document postgres upgrade for cuirass., guix-commits, 2024/12/12
- 15/15: gnu: hyprlang: Fix cross-compilation., guix-commits, 2024/12/12