From f35a4b4ae22046fb04edc165edbb27ee5439aa4b Mon Sep 17 00:00:00 2001 From: Heiko Thiery Date: Wed, 3 Jun 2020 10:12:53 +0200 Subject: [PATCH] utils/check-package: add a check for the new spacing convention The seperation of the fields in the hash file should be 2 spaces for consistency. Since a large number of hash files still violate this rule, exclude it from "make check-package" (and thus from CI). Signed-off-by: Heiko Thiery Cc: Yann E. MORIN Cc: Thomas Petazzoni [Arnout: - Move it to a separate class, so it can be excluded. - Exclude it from "make check-package" ] Signed-off-by: Arnout Vandecappelle (Essensium/Mind) --- Makefile | 2 +- utils/checkpackagelib/lib_hash.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 3099d35158..5fc7137e5a 100644 --- a/Makefile +++ b/Makefile @@ -1258,7 +1258,7 @@ check-flake8: check-package: find $(TOPDIR) -type f \( -name '*.mk' -o -name '*.hash' -o -name 'Config.*' -o -name '*.patch' \) \ - -exec ./utils/check-package --exclude=Sob {} + + -exec ./utils/check-package --exclude=Sob --exclude=HashSpaces {} + include docs/manual/manual.mk -include $(foreach dir,$(BR2_EXTERNAL_DIRS),$(sort $(wildcard $(dir)/docs/*/*.mk))) diff --git a/utils/checkpackagelib/lib_hash.py b/utils/checkpackagelib/lib_hash.py index 3e381119a5..698d24fd6b 100644 --- a/utils/checkpackagelib/lib_hash.py +++ b/utils/checkpackagelib/lib_hash.py @@ -53,3 +53,19 @@ class HashType(_CheckFunction): .format(self.filename, lineno, self.url_to_manual), text, "expected {} hex digits".format(self.len_of_hash[htype])] + + +class HashSpaces(_CheckFunction): + def check_line(self, lineno, text): + if _empty_line_or_comment(text): + return + + fields = text.split() + if len(fields) != 3: + # Handled by HashNumberOfFields + return + + if not re.match(re.escape("{} {} {}".format(*fields)), text): + return ["{}:{}: separation does not match expectation " + "({}#adding-packages-hash)" + .format(self.filename, lineno, self.url_to_manual), text]