me
/
guix
Archived
1
0
Fork 0

lint: Avoid non-literal format strings.

Reported by Mathieu Othacehe <m.othacehe@gmail.com>
at <http://bugs.gnu.org/26498>.

* guix/scripts/lint.scm (warn-if-package-has-input): Rename to...
(package-input-intersection): ... this.  Remove 'linted' and 'message'
parameters.  Return a list of inputs.
(check-inputs-should-be-native): Adjust accordingly.
(check-inputs-should-not-be-an-input-at-all): Likewise.
master
Ludovic Courtès 2017-04-16 11:51:38 +02:00
parent 3689043671
commit 1730c5b509
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
1 changed files with 34 additions and 32 deletions

View File

@ -233,30 +233,27 @@ by two spaces; possible infraction~p at ~{~a~^, ~}")
(format #f (_ "invalid description: ~s") description) (format #f (_ "invalid description: ~s") description)
'description)))) 'description))))
(define (warn-if-package-has-input linted inputs-to-check input-names message) (define (package-input-intersection inputs-to-check input-names)
;; Emit a warning MESSAGE if some of the inputs named in INPUT-NAMES are "Return the intersection between INPUTS-TO-CHECK, the list of input tuples
;; contained in INPUTS-TO-CHECK, which are assumed to be inputs of package of a package, and INPUT-NAMES, a list of package specifications such as
;; LINTED. \"glib:bin\"."
(match inputs-to-check (match inputs-to-check
(((labels packages . outputs) ...) (((labels packages . outputs) ...)
(for-each (lambda (package output) (filter-map (lambda (package output)
(when (package? package) (and (package? package)
(let ((input (string-append (let ((input (string-append
(package-name package) (package-name package)
(if (> (length output) 0) (if (> (length output) 0)
(string-append ":" (car output)) (string-append ":" (car output))
"")))) ""))))
(when (member input input-names) (and (member input input-names)
(emit-warning linted input))))
(format #f (_ message) input) packages outputs))))
'inputs-to-check)))))
packages outputs))))
(define (check-inputs-should-be-native package) (define (check-inputs-should-be-native package)
;; Emit a warning if some inputs of PACKAGE are likely to belong to its ;; Emit a warning if some inputs of PACKAGE are likely to belong to its
;; native inputs. ;; native inputs.
(let ((message "'~a' should probably be a native input") (let ((inputs (package-inputs package))
(inputs (package-inputs package))
(input-names (input-names
'("pkg-config" '("pkg-config"
"extra-cmake-modules" "extra-cmake-modules"
@ -274,24 +271,29 @@ by two spaces; possible infraction~p at ~{~a~^, ~}")
"python-pytest-cov" "python2-pytest-cov" "python-pytest-cov" "python2-pytest-cov"
"python-setuptools-scm" "python2-setuptools-scm" "python-setuptools-scm" "python2-setuptools-scm"
"python-sphinx" "python2-sphinx"))) "python-sphinx" "python2-sphinx")))
(warn-if-package-has-input package inputs input-names message))) (for-each (lambda (input)
(emit-warning
package
(format #f (_ "'~a' should probably be a native input")
input)
'inputs-to-check))
(package-input-intersection inputs input-names))))
(define (check-inputs-should-not-be-an-input-at-all package) (define (check-inputs-should-not-be-an-input-at-all package)
;; Emit a warning if some inputs of PACKAGE are likely to should not be ;; Emit a warning if some inputs of PACKAGE are likely to should not be
;; an input at all. ;; an input at all.
(let ((message "'~a' should probably not be an input at all") (let ((input-names '("python-setuptools"
(inputs (package-inputs package)) "python2-setuptools"
(input-names "python-pip"
'("python-setuptools" "python2-pip")))
"python2-setuptools" (for-each (lambda (input)
"python-pip" (emit-warning
"python2-pip"))) package
(warn-if-package-has-input package (package-inputs package) (format #f
input-names message) (_ "'~a' should probably not be an input at all")
(warn-if-package-has-input package (package-native-inputs package) input)))
input-names message) (package-input-intersection (package-direct-inputs package)
(warn-if-package-has-input package (package-propagated-inputs package) input-names))))
input-names message)))
(define (package-name-regexp package) (define (package-name-regexp package)
"Return a regexp that matches PACKAGE's name as a word at the beginning of a "Return a regexp that matches PACKAGE's name as a word at the beginning of a