fix(static-checks): refactor and improve include order detection

The following changes have been made:

* Adjusted the order in which header files are being located -
  swapped plat_incs and proj_incs, to make sure that the cases
  are prioritized from the most to least specific.
* Removed third_party_incs which had no effect due to a syntax
  error - an if condition checked whether a string is located
  in a list of sets, which always fails. Additionally, includes
  of this type are already being covered by the fallback case.
* Unified include groups into a single ordered dictionary.
* Reworked the logic of the loop that determines the correct
  include group index.
* Removed slashes at the end of some paths.
* Changed the error to a warning and added the word "probably",
  since the detection logic of the script is probabilistic.

Change-Id: I287d9afc3fb753b23e1a213ef0f155d8b0726d46
Signed-off-by: Igor Podgainõi <igor.podgainoi@arm.com>
diff --git a/script/static-checks/check-include-order.py b/script/static-checks/check-include-order.py
index 2160165..b225060 100755
--- a/script/static-checks/check-include-order.py
+++ b/script/static-checks/check-include-order.py
@@ -1,6 +1,6 @@
 #!/usr/bin/env python3
 #
-# Copyright (c) 2019-2023, Arm Limited. All rights reserved.
+# Copyright (c) 2019-2025, Arm Limited. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-3-Clause
 #
@@ -90,40 +90,36 @@
         commit_hash = commit_hash + ":"
 
     # First, check if all includes are in the appropriate group.
+    inc_groups = collections.OrderedDict()
     incs = collections.defaultdict(list)
     error_msgs = []
-    plat_incs = dir_include_paths("plat") | dir_include_paths("include/plat")
-    plat_common_incs = dir_include_paths("include/plat/common")
-    plat_incs.difference_update(plat_common_incs)
-    libc_incs = dir_include_paths("include/lib/libc")
-    proj_incs = dir_include_paths("include/") | dir_include_paths("drivers/")
-    third_party_incs = []
-    third_party_incs.append(dir_include_paths("mbedtls"))
-    third_party_incs.append(dir_include_paths("include/lib/libfdt"))
-    third_party_incs.append(dir_include_paths("lib/compiler-rt"))
-    third_party_incs.append(dir_include_paths("lib/libfdt"))
-    third_party_incs.append(dir_include_paths("lib/zlib"))
+
+    # System (libc) includes
+    inc_groups[0] = dir_include_paths("include/lib/libc")
+    # Platform includes
+    inc_groups[3] = dir_include_paths("plat") | dir_include_paths("include/plat")
+    inc_groups[3].difference_update(dir_include_paths("include/plat/common") |
+                                    dir_include_paths("include/plat/arm"))
+    # Project includes
+    inc_groups[2] = dir_include_paths("include") | dir_include_paths("drivers")
 
     indices = []
 
     for inc in inc_list:
         inc_path = inc[1:-1].replace("..", Path(path).parents[1].as_posix())
-        inc_group_index = int(inc_path not in libc_incs)
 
-        if inc_group_index:
-            if inc_path in third_party_incs:
-                inc_group_index = 1
-            elif inc_path in proj_incs:
-                inc_group_index = 2
-            elif inc_path in plat_incs:
-                inc_group_index = 3
+        inc_group_index = 1 # Third-party includes
+        for index, group in inc_groups.items():
+            if inc_path in group:
+                inc_group_index = index
+                break
 
         incs[inc_group_index].append(inc_path)
         indices.append((inc_group_index, inc))
 
     index_sorted_paths = sorted(indices, key=lambda x: (x[0], x[1][1:-1]))
     if indices != index_sorted_paths:
-        error_msgs.append("Include ordering error, order should be:")
+        error_msgs.append("Include ordering warning, order should probably be:")
         last_group = index_sorted_paths[0][0]
         for inc in index_sorted_paths:
             # Right angle brackets are a special entity in html, convert the