lint: Warn about single-character package names.

A common-sense exception is made for R.

* guix/lint.scm (check-name): New procedure.
(%local-checkers): Add it.
This commit is contained in:
Tobias Geerinckx-Rice via Bug reports for GNU Guix 2021-03-09 22:41:58 +01:00 committed by Tobias Geerinckx-Rice
parent 1b1a61f86a
commit 1126bb9cf3
No known key found for this signature in database
GPG key ID: 0DB0FF884F556D79

View file

@ -6,7 +6,7 @@
;;; Copyright © 2016 Danny Milosavljevic <dannym+a@scratchpost.org>
;;; Copyright © 2016 Hartmut Goebel <h.goebel@crazy-compilers.com>
;;; Copyright © 2017 Alex Kost <alezost@gmail.com>
;;; Copyright © 2017 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2017, 2021 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2017, 2018, 2020 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2018, 2019 Arun Isaac <arunisaac@systemreboot.net>
;;; Copyright © 2020 Chris Marusich <cmmarusich@gmail.com>
@ -170,6 +170,18 @@ (define-record-type* <lint-checker>
(requires-store? lint-checker-requires-store?
(default #f)))
(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))
'())))
(define (properly-starts-sentence? s)
(string-match "^[(\"'`[:upper:][:digit:]]" s))
@ -1446,6 +1458,10 @@ (define (check-formatting package)
(define %local-checkers
(list
(lint-checker
(name 'name)
(description "Validate package names")
(check check-name))
(lint-checker
(name 'description)
(description "Validate package descriptions")