From c58ac2f4984f63e8b9cbbdfea04fb3d8ecfccac1 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Thu, 26 May 2022 13:32:00 +0300 Subject: utils: checkstyle: Run the CLangFormatter last The IncludeOrderFormatter will be extended with more formatting rules that should be applied before clang-format gets run, as it will influence its output. Add a priority mechanism for formatters, and give a negative priority to the CLangFormatter to make it run last. Signed-off-by: Laurent Pinchart Reviewed-by: Umang Jain Reviewed-by: Paul Elder --- utils/checkstyle.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'utils') diff --git a/utils/checkstyle.py b/utils/checkstyle.py index 835f2a9f..66af96ab 100755 --- a/utils/checkstyle.py +++ b/utils/checkstyle.py @@ -279,6 +279,8 @@ class ClassRegistry(type): newclass = super().__new__(cls, clsname, bases, attrs) if bases: bases[0].subclasses.append(newclass) + bases[0].subclasses.sort(key=lambda x: getattr(x, 'priority', 0), + reverse=True) return newclass @@ -568,6 +570,7 @@ class Formatter(metaclass=ClassRegistry): class CLangFormatter(Formatter): patterns = ('*.c', '*.cpp', '*.h') + priority = -1 @classmethod def format(cls, filename, data): -- cgit v1.2.1