From debbugs-submit-bounces@debbugs.gnu.org Thu Apr 15 14:32:06 2021 Received: (at submit) by debbugs.gnu.org; 15 Apr 2021 18:32:06 +0000 Received: from localhost ([127.0.0.1]:39179 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lX6mc-0000S0-FG for submit@debbugs.gnu.org; Thu, 15 Apr 2021 14:32:06 -0400 Received: from lists.gnu.org ([209.51.188.17]:57840) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lX6mZ-0000Rr-Nw for submit@debbugs.gnu.org; Thu, 15 Apr 2021 14:32:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52672) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lX6mX-00054y-Vj for guix-patches@gnu.org; Thu, 15 Apr 2021 14:32:02 -0400 Received: from h87-96-130-155.cust.a3fiber.se ([87.96.130.155]:47486 helo=mail.yoctocell.xyz) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lX6mO-0004m7-NN for guix-patches@gnu.org; Thu, 15 Apr 2021 14:32:01 -0400 From: Xinglu Chen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yoctocell.xyz; s=mail; t=1618511505; bh=NcZC8tMC1i5grbNGiu9BNryoliYTp3NofHQT9VpO84Q=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=LysxMsHl6XH62tKjG6z5D61mwSsiSJ8zM/nFqqbAumPUtQtfyH/544Hq9KLSorJbw HhKmzo1T+/okX9sMYeWLT0MswQUtUoRyf8J3CsKl63yU116AOUY1TdS6dhzoFEEpyp DuIfQvwGOMpLmpvxjLIRa2ev6N41yuaTB01cZZWY= To: guix-patches@gnu.org Subject: [PATCH v2] lint: Warn about underscores in package names. In-Reply-To: References: Message-Id: <94d0b8cb2322ed634442c0ebb79589e5dc05e526.1618511382.git.public@yoctocell.xyz> Date: Thu, 15 Apr 2021 20:31:44 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=87.96.130.155; envelope-from=public@yoctocell.xyz; helo=mail.yoctocell.xyz X-Spam_score_int: 14 X-Spam_score: 1.4 X-Spam_bar: + X-Spam_report: (1.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FROM_SUSPICIOUS_NTLD=0.5, PDS_OTHER_BAD_TLD=1.999, RDNS_DYNAMIC=0.982, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.2 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: 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 nam [...] Content analysis details: (1.2 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [209.51.188.17 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: yoctocell.xyz (xyz)] 0.0 RCVD_IN_MSPIKE_H4 RBL: Very Good reputation (+4) [209.51.188.17 listed in wl.mailspike.net] 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-Debbugs-Envelope-To: submit Cc: Maxime Devos X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.2 (/) 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 =C2=A9 2018, 2019 Arun Isaac ;;; Copyright =C2=A9 2020 Chris Marusich ;;; Copyright =C2=A9 2020 Timothy Sample +;;; Copyright =C2=A9 2021 Xinglu Chen ;;; ;;; 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 (<=3D (string-length name) 1) - (not (string=3D? 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 (<=3D (string-length name) 1) + (not (string=3D? 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 '())))) =20 (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 =C2=A9 2017 Efraim Flashner ;;; Copyright =C2=A9 2018, 2019 Arun Isaac ;;; Copyright =C2=A9 2020 Timothy Sample +;;; Copyright =C2=A9 2021 Xinglu Chen ;;; ;;; This file is part of GNU Guix. ;;; @@ -270,6 +271,12 @@ (description "Imagine this is Taylor UUCP.")))) (check-synopsis-style pkg))) =20 +(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 --=20 2.31.1