* [bug#47804] [PATCH] lint: Warn about underscores in package names.
@ 2021-04-15 16:00 Xinglu Chen
2021-04-15 16:19 ` Maxime Devos
2021-04-15 18:31 ` [bug#47804] [PATCH v2] " Xinglu Chen
0 siblings, 2 replies; 7+ messages in thread
From: Xinglu Chen @ 2021-04-15 16:00 UTC (permalink / raw)
To: 47804
As per section '16.4.2 Package Naming' in the manual, use hyphens
instead of underscores in package names.
* guix/lint.scm (check-name): Check whether the package name contains
underscores.
---
There was some discussion about this on guix-devel[1], but no consensus
was reached. Should we whitelist certain names like “86_64” or something?
[1]: https://yhetil.org/guix-devel/87v991vkpi.fsf@nckx
guix/lint.scm | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/guix/lint.scm b/guix/lint.scm
index a7d6bbba4f..d5ad69475e 100644
--- a/guix/lint.scm
+++ b/guix/lint.scm
@@ -11,6 +11,7 @@
;;; Copyright © 2018, 2019 Arun Isaac <arunisaac@systemreboot.net>
;;; Copyright © 2020 Chris Marusich <cmmarusich@gmail.com>
;;; Copyright © 2020 Timothy Sample <samplet@ngyro.com>
+;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -173,14 +174,20 @@
(define (check-name package)
"Check whether PACKAGE's name matches our guidelines."
(let ((name (package-name package)))
- ;; Currently checks only whether the name is too short.
- (if (and (<= (string-length name) 1)
- (not (string=? name "r"))) ; common-sense exception
- (list
- (make-warning package
- (G_ "name should be longer than a single character")
- #:field 'name))
- '())))
+ (cond
+ ;; Currently checks only whether the name is too short.
+ ((and (<= (string-length name) 1)
+ (not (string=? name "r"))) ; common-sense exception
+ (list
+ (make-warning package
+ (G_ "name should be longer than a single character")
+ #:field 'name)))
+ ((string-match "_" name)
+ (list
+ (make-warning package
+ (G_ "name should use hyphens instead of underscores")
+ #:field 'name)))
+ (else '()))))
(define (properly-starts-sentence? s)
(string-match "^[(\"'`[:upper:][:digit:]]" s))
base-commit: a5bbd38fd131282e928144e869dcdf1e09259085
--
2.31.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [bug#47804] [PATCH] lint: Warn about underscores in package names.
2021-04-15 16:00 [bug#47804] [PATCH] lint: Warn about underscores in package names Xinglu Chen
@ 2021-04-15 16:19 ` Maxime Devos
2021-04-15 18:15 ` Xinglu Chen
2021-04-15 18:31 ` [bug#47804] [PATCH v2] " Xinglu Chen
1 sibling, 1 reply; 7+ messages in thread
From: Maxime Devos @ 2021-04-15 16:19 UTC (permalink / raw)
To: Xinglu Chen, 47804
[-- Attachment #1: Type: text/plain, Size: 2591 bytes --]
On Thu, 2021-04-15 at 18:00 +0200, Xinglu Chen wrote:
> As per section '16.4.2 Package Naming' in the manual, use hyphens
> instead of underscores in package names.
>
> * guix/lint.scm (check-name): Check whether the package name contains
> underscores.
> ---
> There was some discussion about this on guix-devel[1], but no consensus
> was reached. Should we whitelist certain names like “86_64” or something?
I dunno. Perhaps for now, we can accept that the 'check-name' linter is
sometimes overly strict, and punt the exceptions for later?
> [1]: https://yhetil.org/guix-devel/87v991vkpi.fsf@nckx
>
> guix/lint.scm | 23 +++++++++++++++--------
> 1 file changed, 15 insertions(+), 8 deletions(-)
>
> diff --git a/guix/lint.scm b/guix/lint.scm
> index a7d6bbba4f..d5ad69475e 100644
> --- a/guix/lint.scm
> +++ b/guix/lint.scm
> @@ -11,6 +11,7 @@
> ;;; Copyright © 2018, 2019 Arun Isaac <arunisaac@systemreboot.net>
> ;;; Copyright © 2020 Chris Marusich <cmmarusich@gmail.com>
> ;;; Copyright © 2020 Timothy Sample <samplet@ngyro.com>
> +;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
> ;;;
> ;;; This file is part of GNU Guix.
> ;;;
> @@ -173,14 +174,20 @@
> (define (check-name package)
> "Check whether PACKAGE's name matches our guidelines."
> (let ((name (package-name package)))
> - ;; Currently checks only whether the name is too short.
> - (if (and (<= (string-length name) 1)
> - (not (string=? name "r"))) ; common-sense exception
> - (list
> - (make-warning package
> - (G_ "name should be longer than a single character")
> - #:field 'name))
> - '())))
> + (cond
> + ;; Currently checks only whether the name is too short.
> + ((and (<= (string-length name) 1)
> + (not (string=? name "r"))) ; common-sense exception
> + (list
> + (make-warning package
> + (G_ "name should be longer than a single character")
> + #:field 'name)))
> + ((string-match "_" name)
> + (list
> + (make-warning package
> + (G_ "name should use hyphens instead of underscores")
> + #:field 'name)))
> + (else '()))))
I didn't test this, but that seems about right.
Ideally, you should add a corresponding test in tests/lint.scm
(IIRC, maybe the linter tests are elsewhere).
However, Guix is currently in the "string freeze", so this cannot yet be merged,
IIUC.
Greetings,
Maxime.
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* [bug#47804] [PATCH] lint: Warn about underscores in package names.
2021-04-15 16:19 ` Maxime Devos
@ 2021-04-15 18:15 ` Xinglu Chen
2021-04-16 10:19 ` Maxime Devos
0 siblings, 1 reply; 7+ messages in thread
From: Xinglu Chen @ 2021-04-15 18:15 UTC (permalink / raw)
To: Maxime Devos, 47804
On Thu, Apr 15 2021, Maxime Devos wrote:
>> There was some discussion about this on guix-devel[1], but no
>> consensus was reached. Should we whitelist certain names like
>> “86_64” or something?
>
> I dunno. Perhaps for now, we can accept that the 'check-name' linter
> is sometimes overly strict, and punt the exceptions for later?
Ok, that sounds like a good idea.
> I didn't test this, but that seems about right. Ideally, you should
> add a corresponding test in tests/lint.scm (IIRC, maybe the linter
> tests are elsewhere).
Will do.
> However, Guix is currently in the "string freeze", so this cannot yet
> be merged, IIUC.
I thought the “string freeze” was for the manual, or did I miss
something?
Thanks for the review!
^ permalink raw reply [flat|nested] 7+ messages in thread
* [bug#47804] [PATCH v2] lint: Warn about underscores in package names.
2021-04-15 16:00 [bug#47804] [PATCH] lint: Warn about underscores in package names Xinglu Chen
2021-04-15 16:19 ` Maxime Devos
@ 2021-04-15 18:31 ` Xinglu Chen
2021-04-16 20:54 ` bug#47804: [PATCH] " Ludovic Courtès
1 sibling, 1 reply; 7+ messages in thread
From: Xinglu Chen @ 2021-04-15 18:31 UTC (permalink / raw)
To: 47804; +Cc: Maxime Devos
As per section '16.4.2 Package Naming' in the manual, use hyphens
instead of underscores in package names.
* guix/lint.scm (check-name): Check whether the package name contains
underscores.
* tests/lint.scm ("name: use underscore in package name"): New test.
---
Changes since v1:
- Add test for package name with underscore.
guix/lint.scm | 24 ++++++++++++++++--------
tests/lint.scm | 7 +++++++
2 files changed, 23 insertions(+), 8 deletions(-)
diff --git a/guix/lint.scm b/guix/lint.scm
index a7d6bbba4f..38699e2927 100644
--- a/guix/lint.scm
+++ b/guix/lint.scm
@@ -11,6 +11,7 @@
;;; Copyright © 2018, 2019 Arun Isaac <arunisaac@systemreboot.net>
;;; Copyright © 2020 Chris Marusich <cmmarusich@gmail.com>
;;; Copyright © 2020 Timothy Sample <samplet@ngyro.com>
+;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -81,6 +82,7 @@
check-synopsis-style
check-derivation
check-home-page
+ check-name
check-source
check-source-file-name
check-source-unstable-tarball
@@ -173,14 +175,20 @@
(define (check-name package)
"Check whether PACKAGE's name matches our guidelines."
(let ((name (package-name package)))
- ;; Currently checks only whether the name is too short.
- (if (and (<= (string-length name) 1)
- (not (string=? name "r"))) ; common-sense exception
- (list
- (make-warning package
- (G_ "name should be longer than a single character")
- #:field 'name))
- '())))
+ (cond
+ ;; Currently checks only whether the name is too short.
+ ((and (<= (string-length name) 1)
+ (not (string=? name "r"))) ; common-sense exception
+ (list
+ (make-warning package
+ (G_ "name should be longer than a single character")
+ #:field 'name)))
+ ((string-match "_" name)
+ (list
+ (make-warning package
+ (G_ "name should use hyphens instead of underscores")
+ #:field 'name)))
+ (else '()))))
(define (properly-starts-sentence? s)
(string-match "^[(\"'`[:upper:][:digit:]]" s))
diff --git a/tests/lint.scm b/tests/lint.scm
index bd8604f589..a2c8665142 100644
--- a/tests/lint.scm
+++ b/tests/lint.scm
@@ -8,6 +8,7 @@
;;; Copyright © 2017 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2018, 2019 Arun Isaac <arunisaac@systemreboot.net>
;;; Copyright © 2020 Timothy Sample <samplet@ngyro.com>
+;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -270,6 +271,12 @@
(description "Imagine this is Taylor UUCP."))))
(check-synopsis-style pkg)))
+(test-equal "name: use underscore in package name"
+ "name should use hyphens instead of underscores"
+ (single-lint-warning-message
+ (let ((pkg (dummy-package "under_score")))
+ (check-name pkg))))
+
(test-equal "inputs: pkg-config is probably a native input"
"'pkg-config' should probably be a native input"
(single-lint-warning-message
base-commit: a5bbd38fd131282e928144e869dcdf1e09259085
--
2.31.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [bug#47804] [PATCH] lint: Warn about underscores in package names.
2021-04-15 18:15 ` Xinglu Chen
@ 2021-04-16 10:19 ` Maxime Devos
0 siblings, 0 replies; 7+ messages in thread
From: Maxime Devos @ 2021-04-16 10:19 UTC (permalink / raw)
To: Xinglu Chen, 47804
[-- Attachment #1: Type: text/plain, Size: 469 bytes --]
On Thu, 2021-04-15 at 20:15 +0200, Xinglu Chen wrote:
> On Thu, Apr 15 2021, Maxime Devos wrote:
> [...]
>
> > However, Guix is currently in the "string freeze", so this cannot yet
> > be merged, IIUC.
>
> I thought the “string freeze” was for the manual, or did I miss
> something?
<https://lists.gnu.org/archive/html/guix-devel/2021-04/msg00180.html>
The freeze if for both the manual and guix itself (but not the packages).
Greetings,
Maxime.
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#47804: [PATCH] lint: Warn about underscores in package names.
2021-04-15 18:31 ` [bug#47804] [PATCH v2] " Xinglu Chen
@ 2021-04-16 20:54 ` Ludovic Courtès
2021-04-16 21:42 ` [bug#47804] " Julien Lepiller
0 siblings, 1 reply; 7+ messages in thread
From: Ludovic Courtès @ 2021-04-16 20:54 UTC (permalink / raw)
To: Xinglu Chen; +Cc: 47804-done, Maxime Devos
[-- Attachment #1: Type: text/plain, Size: 524 bytes --]
Hi,
Xinglu Chen <public@yoctocell.xyz> skribis:
> As per section '16.4.2 Package Naming' in the manual, use hyphens
> instead of underscores in package names.
>
> * guix/lint.scm (check-name): Check whether the package name contains
> underscores.
> * tests/lint.scm ("name: use underscore in package name"): New test.
Applied with the minor change below, which avoids regexps
(‘string-match’ performs regexp matches, which is overkill here).
Thank you and thanks Maxime for the review!
Ludo’.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 464 bytes --]
diff --git a/guix/lint.scm b/guix/lint.scm
index 38699e2927..1bebfe03d3 100644
--- a/guix/lint.scm
+++ b/guix/lint.scm
@@ -183,7 +183,7 @@
(make-warning package
(G_ "name should be longer than a single character")
#:field 'name)))
- ((string-match "_" name)
+ ((string-index name #\_)
(list
(make-warning package
(G_ "name should use hyphens instead of underscores")
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [bug#47804] [PATCH] lint: Warn about underscores in package names.
2021-04-16 20:54 ` bug#47804: [PATCH] " Ludovic Courtès
@ 2021-04-16 21:42 ` Julien Lepiller
0 siblings, 0 replies; 7+ messages in thread
From: Julien Lepiller @ 2021-04-16 21:42 UTC (permalink / raw)
To: 47804, ludo, public; +Cc: 47804-done, Maxime Devos
Le 16 avril 2021 16:54:47 GMT-04:00, "Ludovic Courtès" <ludo@gnu.org> a écrit :
>Hi,
>
>Xinglu Chen <public@yoctocell.xyz> skribis:
>
>> As per section '16.4.2 Package Naming' in the manual, use hyphens
>> instead of underscores in package names.
>>
>> * guix/lint.scm (check-name): Check whether the package name contains
>> underscores.
>> * tests/lint.scm ("name: use underscore in package name"): New test.
>
>Applied with the minor change below, which avoids regexps
>(‘string-match’ performs regexp matches, which is overkill here).
>
>Thank you and thanks Maxime for the review!
>
>Ludo’.
Hm… unless I'm mistaken, this patch adds a string to the guix domain, which is part of the string freeze.
The guix-packages is not part of the string freeze, that is to say synopsis and description of packages, only.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-04-16 22:16 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-15 16:00 [bug#47804] [PATCH] lint: Warn about underscores in package names Xinglu Chen
2021-04-15 16:19 ` Maxime Devos
2021-04-15 18:15 ` Xinglu Chen
2021-04-16 10:19 ` Maxime Devos
2021-04-15 18:31 ` [bug#47804] [PATCH v2] " Xinglu Chen
2021-04-16 20:54 ` bug#47804: [PATCH] " Ludovic Courtès
2021-04-16 21:42 ` [bug#47804] " Julien Lepiller
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).