Explorar o código

Meta: Ignore local includes of .moc files

These are generated by Qt and added to the include path automatically by
CMake.
Timothy Flynn %!s(int64=2) %!d(string=hai) anos
pai
achega
0fd35b4dd8
Modificáronse 1 ficheiros con 12 adicións e 0 borrados
  1. 12 0
      Meta/check-style.py

+ 12 - 0
Meta/check-style.py

@@ -51,12 +51,19 @@ BAD_INCLUDE_LIBC = re.compile("# *include <LibC/")
 ANY_INCLUDE_PATTERN = re.compile('^ *# *include\\b.*[>"](?!\\)).*$', re.M)
 SYSTEM_INCLUDE_PATTERN = re.compile("^ *# *include *<([^>]+)>(?: /[*/].*)?$")
 LOCAL_INCLUDE_PATTERN = re.compile('^ *# *include *"([^>]+)"(?: /[*/].*)?$')
+
 INCLUDE_CHECK_EXCLUDES = {
     "Userland/Libraries/LibCodeComprehension/Cpp/Tests/",
     "Userland/Libraries/LibCpp/Tests/parser/",
     "Userland/Libraries/LibCpp/Tests/preprocessor/",
 }
 
+LOCAL_INCLUDE_SUFFIX_EXCLUDES = [
+    # Some Qt files are required to include their .moc files, which will be located in a deep
+    # subdirectory that we won't find from here.
+    '.moc',
+]
+
 
 def should_check_file(filename):
     if not filename.endswith('.cpp') and not filename.endswith('.h'):
@@ -126,8 +133,13 @@ def run():
                     if filename not in errors_include_weird_format:
                         errors_include_weird_format.append(filename)
                     continue
+
                 relative_filename = local_match.group(1)
                 referenced_file = file_directory.joinpath(relative_filename)
+
+                if referenced_file.suffix in LOCAL_INCLUDE_SUFFIX_EXCLUDES:
+                    continue
+
                 if not referenced_file.exists():
                     print(f"In {filename}: Cannot find {referenced_file}")
                     if filename not in errors_include_missing_local: