diff options
author | Xinglu Chen <public@yoctocell.xyz> | 2021-04-15 20:31:44 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2021-04-16 23:25:23 +0200 |
commit | c68070e4eefd25118b368bd7af872f65ab739fc7 (patch) | |
tree | 9b1d630da21e4c6623f862c2ab115d523d0a6bec | |
parent | 5b35c9adc899749a0bd96a0e6d2c3bbf88e38963 (diff) | |
download | guix-c68070e4eefd25118b368bd7af872f65ab739fc7.tar.gz guix-c68070e4eefd25118b368bd7af872f65ab739fc7.zip |
lint: Warn about underscores in package names.
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.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
-rw-r--r-- | guix/lint.scm | 24 | ||||
-rw-r--r-- | tests/lint.scm | 7 |
2 files changed, 23 insertions, 8 deletions
diff --git a/guix/lint.scm b/guix/lint.scm index a7d6bbba4f..1bebfe03d3 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-index 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 |