guix: lint: Check descriptions for trademark signs.

* guix/scripts/lint.scm (check-description-style): Emit a warning if
trademark signs found in description.
* tests/lint.scm (description: may not contain trademark signs): Add
test.
This commit is contained in:
Eric Bavier 2016-08-23 02:08:02 -05:00
parent 334bda9a9e
commit 83f18e0653
No known key found for this signature in database
GPG key ID: 1EBBD204781F962C
2 changed files with 28 additions and 1 deletions

View file

@ -161,6 +161,18 @@ (define (check-texinfo-markup description)
'description) 'description)
#f))) #f)))
(define (check-trademarks description)
"Check that DESCRIPTION does not contain '' or '®' characters. See
http://www.gnu.org/prep/standards/html_node/Trademarks.html."
(match (string-index description (char-set #\™ #\®))
((and (? number?) index)
(emit-warning package
(format #f (_ "description should not contain ~
trademark sign '~a' at ~d")
(string-ref description index) index)
'description))
(else #t)))
(define (check-proper-start description) (define (check-proper-start description)
(unless (or (properly-starts-sentence? description) (unless (or (properly-starts-sentence? description)
(string-prefix-ci? (package-name package) description)) (string-prefix-ci? (package-name package) description))
@ -191,6 +203,7 @@ (define (check-end-of-sentence-space description)
(if (string? description) (if (string? description)
(begin (begin
(check-not-empty description) (check-not-empty description)
(check-trademarks description)
;; Use raw description for this because Texinfo rendering ;; Use raw description for this because Texinfo rendering
;; automatically fixes end of sentence space. ;; automatically fixes end of sentence space.
(check-end-of-sentence-space description) (check-end-of-sentence-space description)

View file

@ -1,6 +1,6 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2012, 2013 Cyril Roelandt <tipecaml@gmail.com> ;;; Copyright © 2012, 2013 Cyril Roelandt <tipecaml@gmail.com>
;;; Copyright © 2014, 2015 Eric Bavier <bavier@member.fsf.org> ;;; Copyright © 2014, 2015, 2016 Eric Bavier <bavier@member.fsf.org>
;;; Copyright © 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2015, 2016 Mathieu Lirzin <mthl@gnu.org> ;;; Copyright © 2015, 2016 Mathieu Lirzin <mthl@gnu.org>
;;; ;;;
@ -203,6 +203,20 @@ (define-syntax-rule (with-warnings body ...)
"E.g. Foo, i.e. Bar resp. Baz (a.k.a. DVD).")))) "E.g. Foo, i.e. Bar resp. Baz (a.k.a. DVD)."))))
(check-description-style pkg))))) (check-description-style pkg)))))
(test-assert "description: may not contain trademark signs"
(and (->bool
(string-contains (with-warnings
(let ((pkg (dummy-package "x"
(description "Does The Right Thing™"))))
(check-description-style pkg)))
"should not contain trademark sign"))
(->bool
(string-contains (with-warnings
(let ((pkg (dummy-package "x"
(description "Works with Format®"))))
(check-description-style pkg)))
"should not contain trademark sign"))))
(test-assert "synopsis: not a string" (test-assert "synopsis: not a string"
(->bool (->bool
(string-contains (with-warnings (string-contains (with-warnings