From patchwork Sat Oct 5 12:22:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerzy Grzegorek X-Patchwork-Id: 1172191 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.137; helo=fraxinus.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Uln+UeGI"; dkim-atps=neutral Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46lm9T6qvwz9sPv for ; Sat, 5 Oct 2019 22:23:09 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 49FFF86BF7; Sat, 5 Oct 2019 12:23:08 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CkpyQrJFlXay; Sat, 5 Oct 2019 12:23:06 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id DE38186A32; Sat, 5 Oct 2019 12:23:06 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 430171BF29F for ; Sat, 5 Oct 2019 12:23:04 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 403AA87863 for ; Sat, 5 Oct 2019 12:23:04 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zLEQymuCMm3K for ; Sat, 5 Oct 2019 12:23:03 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-lj1-f195.google.com (mail-lj1-f195.google.com [209.85.208.195]) by whitealder.osuosl.org (Postfix) with ESMTPS id BA43387AB6 for ; Sat, 5 Oct 2019 12:23:02 +0000 (UTC) Received: by mail-lj1-f195.google.com with SMTP id j19so9146683lja.1 for ; Sat, 05 Oct 2019 05:23:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=UDuJrq6uhLRXa/TKg4NyzNRknmFnbdz/DJneYrhx4KA=; b=Uln+UeGIn0M/k69AsDiVaLWXbQ3VaFMx9zk4+hvAUNWejcqq04cvpHcOhM7B5Ao2YI vBKxqXlCtcVItIuHaOXn8pHTn9kGjPQ1LGBQhR0gPpcfvmf3zyzb0s3JqpmmU7acbyPP OX5Q2XmW0vUd81W0zJ+sBqNXREZnAPCHTzxecM5Yr8CXyZeYLsXxdzY4WOLe9poWm+Qf BbsT82me1lvqTeh05VccFl8AnmyHU8OcUja82PXTDNj4kefXDkojGuxvO5EKv7iYtq1d TazBQE6vkxa/uM0S11rGHfIEj7C6ZL09mKXDruOQHJFJmXaXC4KVOxiYpEzuWTPTCty/ yzEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=UDuJrq6uhLRXa/TKg4NyzNRknmFnbdz/DJneYrhx4KA=; b=Bxb7G/75REy8sbD3EPHpXmCYBuJYjNcCQTLOGSnIwkfBNoNfKmMt5lqXaOdul9XSir 3i7lMu6mUX37unJxxABF2olwGO1K56rmu9iRGrmYM0CS50cBLhOtMwR7OHZ7BBlxf0O1 5HkKMlr+GNSEEt37sH+64zWcoTKucY5v2BSVGswJD1rvFY2f/44CM6YnimG/BcmRSHfJ PH55QHjBmumqA/35Kjcu8k+v9AU4z//wqTzFH0OJNnTH6dJhRm4bbHB8rG6B2EUACU0R 0OmOYSefU/0c0n/JdTnWbMrxeewVbKjAxek5mx2joHcrJlXq7Y0obEzy8pm2JpwLYluq qxsA== X-Gm-Message-State: APjAAAWctvJV7yDjz9sjAA7ymtERn/R5phtGfT2Dkp9oY/b8n7L4lK4G 91n1wTXRb8EeXjWuxwNPYjD8XGHb X-Google-Smtp-Source: APXvYqwtEU8N3s2sO8dAtGD7m5/EoK61QlazkcbNZh1dqQDB98WZaGFUYESBQw/4zyo+NMS7HEPgxg== X-Received: by 2002:a2e:7407:: with SMTP id p7mr8587406ljc.182.1570278180750; Sat, 05 Oct 2019 05:23:00 -0700 (PDT) Received: from localhost.localdomain (user-5-173-241-167.play-internet.pl. [5.173.241.167]) by smtp.gmail.com with ESMTPSA id h10sm1856214ljb.14.2019.10.05.05.22.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2019 05:23:00 -0700 (PDT) From: Jerzy Grzegorek To: buildroot@busybox.net Date: Sat, 5 Oct 2019 14:22:23 +0200 Message-Id: <20191005122227.7297-10-jerzy.m.grzegorek@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191005122227.7297-1-jerzy.m.grzegorek@gmail.com> References: <20191005122227.7297-1-jerzy.m.grzegorek@gmail.com> Subject: [Buildroot] [PATCH v2 09/13] utils/checkpackagelib: CommentsMenusPackagesOrder: check the order of comments menu X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jerzy Grzegorek , Ricardo Martincoski MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" At any level if the 'comment ...' line occurs for the first time a new state '-comment' is added and all arrays elements for that level are initialized. For the second and subsequent time only packages arrays elements are initialized. The menu of comments corresponds to menu of packages of lower level. Only the valid comments are compared. The comment is valid only if there is at least one a 'source ...' line after it and before the next 'comment ...', 'menu ...' or 'if ...' line. The alphabetical order of comments at that level is checked until the first error occurs. Signed-off-by: Jerzy Grzegorek Cc: Ricardo Martincoski --- utils/checkpackagelib/lib_config.py | 43 ++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/utils/checkpackagelib/lib_config.py b/utils/checkpackagelib/lib_config.py index 709dbae0fe..06d45bd6ec 100644 --- a/utils/checkpackagelib/lib_config.py +++ b/utils/checkpackagelib/lib_config.py @@ -62,10 +62,13 @@ class AttributesOrder(_CheckFunction): class CommentsMenusPackagesOrder(_CheckFunction): def before(self): + self.comment = [""] + self.comments_order_checking = [False] self.level = 0 self.menu_of_packages = ["The top level menu"] self.new_package = "" self.package = [""] + self.print_comment_warning = [True] self.print_package_warning = [True] self.state = "" @@ -84,6 +87,16 @@ class CommentsMenusPackagesOrder(_CheckFunction): def initialize_level_elements(self, text): self.level = self.get_level() + + try: + self.comment[self.level] = "" + self.comments_order_checking[self.level] = False + self.print_comment_warning[self.level] = True + except IndexError: + self.comment.append("") + self.comments_order_checking.append(False) + self.print_comment_warning.append(True) + self.initialize_package_level_elements(text) def check_line(self, lineno, text): @@ -101,7 +114,12 @@ class CommentsMenusPackagesOrder(_CheckFunction): if not self.state.endswith("-comment"): self.state += "-comment" - self.initialize_level_elements(text) + self.initialize_level_elements(text) + else: + self.initialize_package_level_elements(text) + + if self.print_comment_warning[self.level]: + self.comments_order_checking[self.level] = True elif text.startswith("if "): self.state += "-if" @@ -145,6 +163,29 @@ class CommentsMenusPackagesOrder(_CheckFunction): self.level = self.get_level() elif source_line: + if self.comments_order_checking[self.level]: + + self.comments_order_checking[self.level] = False + + new_comment = self.menu_of_packages[self.level][9: -1:] + + if self.comment[self.level] != "" and \ + self.print_comment_warning[self.level] and \ + new_comment < self.comment[self.level]: + self.print_comment_warning[self.level] = False + prefix = "{}:{}: ".format(self.filename, lineno) + spaces = " " * len(prefix) + return ["{prefix}Comments in: {menu},\n" + "{spaces}are not alphabetically ordered;\n" + "{spaces}correct order: '-', '_', digits, capitals, lowercase;\n" + "{spaces}first incorrect comment: {comment}" + .format(prefix=prefix, spaces=spaces, + menu=self.menu_of_packages[self.level-1], + comment=new_comment), + text] + + self.comment[self.level] = new_comment + self.new_package = source_line.group(1) # We order _ before A, so replace it with .