lint: Add 'license' checker.
* guix/scripts/lint.scm (check-license): New procedure. (%checkers): Add 'license' checker. * tests/lint.scm ("license: invalid license"): New test.
This commit is contained in:
parent
718a2bde42
commit
52b9efe337
|
@ -24,6 +24,7 @@
|
||||||
#:use-module (guix download)
|
#:use-module (guix download)
|
||||||
#:use-module (guix ftp-client)
|
#:use-module (guix ftp-client)
|
||||||
#:use-module (guix packages)
|
#:use-module (guix packages)
|
||||||
|
#:use-module (guix licenses)
|
||||||
#:use-module (guix records)
|
#:use-module (guix records)
|
||||||
#:use-module (guix ui)
|
#:use-module (guix ui)
|
||||||
#:use-module (guix utils)
|
#:use-module (guix utils)
|
||||||
|
@ -56,6 +57,7 @@
|
||||||
check-derivation
|
check-derivation
|
||||||
check-home-page
|
check-home-page
|
||||||
check-source
|
check-source
|
||||||
|
check-license
|
||||||
check-formatting
|
check-formatting
|
||||||
|
|
||||||
%checkers
|
%checkers
|
||||||
|
@ -518,6 +520,16 @@ descriptions maintained upstream."
|
||||||
(format #f (_ "failed to create derivation: ~s~%")
|
(format #f (_ "failed to create derivation: ~s~%")
|
||||||
args)))))
|
args)))))
|
||||||
|
|
||||||
|
(define (check-license package)
|
||||||
|
"Warn about type errors of the 'license' field of PACKAGE."
|
||||||
|
(match (package-license package)
|
||||||
|
((or (? license?)
|
||||||
|
((? license?) ...))
|
||||||
|
#t)
|
||||||
|
(x
|
||||||
|
(emit-warning package (_ "invalid license field")
|
||||||
|
'license))))
|
||||||
|
|
||||||
|
|
||||||
;;;
|
;;;
|
||||||
;;; Source code formatting.
|
;;; Source code formatting.
|
||||||
|
@ -619,6 +631,13 @@ them for PACKAGE."
|
||||||
(name 'home-page)
|
(name 'home-page)
|
||||||
(description "Validate home-page URLs")
|
(description "Validate home-page URLs")
|
||||||
(check check-home-page))
|
(check check-home-page))
|
||||||
|
(lint-checker
|
||||||
|
(name 'license)
|
||||||
|
;; TRANSLATORS: <license> is the name of a data type and must not be
|
||||||
|
;; translated.
|
||||||
|
(description "Make sure the 'license' field is a <license> \
|
||||||
|
or a list thereof")
|
||||||
|
(check check-license))
|
||||||
(lint-checker
|
(lint-checker
|
||||||
(name 'source)
|
(name 'source)
|
||||||
(description "Validate source URLs")
|
(description "Validate source URLs")
|
||||||
|
|
|
@ -329,6 +329,12 @@ requests."
|
||||||
(check-derivation pkg)))
|
(check-derivation pkg)))
|
||||||
"failed to create derivation")))
|
"failed to create derivation")))
|
||||||
|
|
||||||
|
(test-assert "license: invalid license"
|
||||||
|
(string-contains
|
||||||
|
(with-warnings
|
||||||
|
(check-license (dummy-package "x" (license #f))))
|
||||||
|
"invalid license"))
|
||||||
|
|
||||||
(test-assert "home-page: wrong home-page"
|
(test-assert "home-page: wrong home-page"
|
||||||
(->bool
|
(->bool
|
||||||
(string-contains
|
(string-contains
|
||||||
|
|
Loading…
Reference in New Issue