From patchwork Thu Apr 15 18:31:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Xinglu Chen X-Patchwork-Id: 28577 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 55F1227BC77; Thu, 15 Apr 2021 19:33:31 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, T_DKIM_INVALID,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 9675327BC76 for ; Thu, 15 Apr 2021 19:33:30 +0100 (BST) Received: from localhost ([::1]:56942 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lX6nx-0005PX-NP for patchwork@mira.cbaines.net; Thu, 15 Apr 2021 14:33:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53086) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lX6nW-0005OK-Mn for guix-patches@gnu.org; Thu, 15 Apr 2021 14:33:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:55869) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lX6nW-0005Dg-DV for guix-patches@gnu.org; Thu, 15 Apr 2021 14:33:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lX6nW-0000TU-AV for guix-patches@gnu.org; Thu, 15 Apr 2021 14:33:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#47804] [PATCH v2] lint: Warn about underscores in package names. Resent-From: Xinglu Chen Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 15 Apr 2021 18:33:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47804 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 47804@debbugs.gnu.org Cc: Maxime Devos X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.16185115261740 (code B ref -1); Thu, 15 Apr 2021 18:33:02 +0000 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= 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 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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches 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(-) base-commit: a5bbd38fd131282e928144e869dcdf1e09259085 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 ;;; Copyright © 2020 Chris Marusich ;;; Copyright © 2020 Timothy Sample +;;; Copyright © 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 (<= (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 ;;; Copyright © 2018, 2019 Arun Isaac ;;; Copyright © 2020 Timothy Sample +;;; Copyright © 2021 Xinglu Chen ;;; ;;; 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