me
/
guix
Archived
1
0
Fork 0

guix: lint: Use string-suffix? and string-prefix? where appropriate.

* guix/scripts/lint.scm (check-synopsis): Use string-suffix? and
  string-prefix? in place of string-take and string=?.
master
Eric Bavier 2014-10-22 09:20:20 -05:00
parent ec322be248
commit 86a4126348
1 changed files with 9 additions and 10 deletions

View File

@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2014 Cyril Roelandt <tipecaml@gmail.com> ;;; Copyright © 2014 Cyril Roelandt <tipecaml@gmail.com>
;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -103,15 +104,15 @@
;; Emit a warning if stylistic issues are found in the synopsis of PACKAGE. ;; Emit a warning if stylistic issues are found in the synopsis of PACKAGE.
(define (check-final-period synopsis) (define (check-final-period synopsis)
;; Synopsis should not end with a period, except for some special cases. ;; Synopsis should not end with a period, except for some special cases.
(if (and (string=? (string-take-right synopsis 1) ".") (if (and (string-suffix? "." synopsis)
(not (string=? (string-take-right synopsis 4) "etc."))) (not (string-suffix? "etc." synopsis)))
(emit-warning package (emit-warning package
"no period allowed at the end of the synopsis" "no period allowed at the end of the synopsis"
'synopsis))) 'synopsis)))
(define (check-start-article synopsis) (define (check-start-article synopsis)
(if (or (string-ci=? (string-take synopsis 2) "A ") (if (or (string-prefix-ci? "A " synopsis)
(string-ci=? (string-take synopsis 3) "An ")) (string-prefix-ci? "An " synopsis))
(emit-warning package (emit-warning package
"no article allowed at the beginning of the synopsis" "no article allowed at the beginning of the synopsis"
'synopsis))) 'synopsis)))
@ -130,12 +131,10 @@
'synopsis))) 'synopsis)))
(define (check-start-with-package-name synopsis) (define (check-start-with-package-name synopsis)
(let ((idx (string-contains-ci synopsis (package-name package)))) (when (string-prefix-ci? (package-name package) synopsis)
(when (and idx (emit-warning package
(= idx 0)) "synopsis should not start with the package name"
(emit-warning package 'synopsis)))
"synopsis should not start with the package name")
'synopsis)))
(let ((synopsis (package-synopsis package))) (let ((synopsis (package-synopsis package)))
(if (string? synopsis) (if (string? synopsis)