From: Xinglu Chen <public@yoctocell.xyz>
To: 47804@debbugs.gnu.org
Cc: Maxime Devos <maximedevos@telenet.be>
Subject: [bug#47804] [PATCH v2] lint: Warn about underscores in package names.
Date: Thu, 15 Apr 2021 20:31:44 +0200 [thread overview]
Message-ID: <94d0b8cb2322ed634442c0ebb79589e5dc05e526.1618511382.git.public@yoctocell.xyz> (raw)
In-Reply-To: <dc3d1c690b40861eab4d623fb8bca88f4194e209.1618502119.git.public@yoctocell.xyz>
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
next prev parent reply other threads:[~2021-04-15 18:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Xinglu Chen [this message]
2021-04-16 20:54 ` bug#47804: " Ludovic Courtès
2021-04-16 21:42 ` [bug#47804] " Julien Lepiller
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=94d0b8cb2322ed634442c0ebb79589e5dc05e526.1618511382.git.public@yoctocell.xyz \
--to=public@yoctocell.xyz \
--cc=47804@debbugs.gnu.org \
--cc=maximedevos@telenet.be \
/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.