[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/4] lint: Add 'inputs-should-be-sorted' check.
From: |
David Craven |
Subject: |
[PATCH 3/4] lint: Add 'inputs-should-be-sorted' check. |
Date: |
Tue, 19 Jul 2016 18:49:15 +0200 |
* guix/scripts/lint.scm (check-inputs-should-be-sorted): Add it.
(lint-checker): Add it.
---
guix/scripts/lint.scm | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/guix/scripts/lint.scm b/guix/scripts/lint.scm
index d64a066..d3a82c9 100644
--- a/guix/scripts/lint.scm
+++ b/guix/scripts/lint.scm
@@ -220,6 +220,21 @@ by two spaces; possible infraction~p at ~{~a~^, ~}")
(when (string-suffix? ":bin" package-name) (warn package-name)))
labels)))))))
+(define (check-inputs-should-be-sorted package)
+ ;; Emit a warning if inputs, native-inputs or propagated-inputs are not
sorted.
+ (define (check-inputs accessor string symbol)
+ (let ((inputs (accessor package)))
+ (match inputs
+ (((labels packages . _) ...)
+ (let ((package-names (map package-name (filter package? packages))))
#t
+ (unless (sorted? package-names string<?)
+ (emit-warning package
+ (format (_ "has unordered ~s") string) symbol)))))))
+
+ (check-inputs package-inputs "inputs" 'inputs)
+ (check-inputs package-native-inputs "native-inputs" 'native-inputs)
+ (check-inputs package-propagated-inputs "propagated-inputs"
'propagated-inputs))
+
(define (package-name-regexp package)
"Return a regexp that matches PACKAGE's name as a word at the beginning of a
line."
@@ -788,6 +803,10 @@ them for PACKAGE."
(description "Identify inputs that should be native inputs")
(check check-inputs-should-be-native))
(lint-checker
+ (name 'inputs-should-be-sorted)
+ (description "Identify packages with unsorted inputs")
+ (check check-inputs-should-be-sorted))
+ (lint-checker
(name 'patch-file-names)
(description "Validate file names and availability of patches")
(check check-patch-file-names))
--
2.9.0
- [PATCH 0/4] Dipping my toes into guix source., David Craven, 2016/07/19
- [PATCH 3/4] lint: Add 'inputs-should-be-sorted' check.,
David Craven <=
- [PATCH 4/4] environment: Add '--debug' flag., David Craven, 2016/07/19
- Re: [PATCH 4/4] environment: Add '--debug' flag., Thompson, David, 2016/07/19
- Re: [PATCH 4/4] environment: Add '--debug' flag., Tobias Geerinckx-Rice, 2016/07/19
- Re: [PATCH 4/4] environment: Add '--debug' flag., David Craven, 2016/07/19
- Re: [PATCH 4/4] environment: Add '--debug' flag., David Craven, 2016/07/19
- Re: [PATCH 4/4] environment: Add '--debug' flag., Thompson, David, 2016/07/19
- Re: [PATCH 4/4] environment: Add '--debug' flag., David Craven, 2016/07/19
- Re: [PATCH 4/4] environment: Add '--debug' flag., Leo Famulari, 2016/07/20