From 20b6399a3813c6187d6d007360dcbf2dd42176b8 Mon Sep 17 00:00:00 2001 From: Matan Lurey Date: Fri, 22 Sep 2023 09:30:15 -0700 Subject: [PATCH] Enable checking headers with Clang Tidy. (flutter/engine#46009) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes https://github.com/flutter/flutter/issues/134969. Turns out this was literally 1 line. Tested locally: ```shell dart tools/clang_tidy/bin/main.dart \ --target-variant host_debug_unopt_arm64 \ --lint-all \ --checks="-*,llvm-header-guard" ```
Local Test Results Here is a tiny snippet showing this is indeed doing something: ```txt [0:02] Jobs: 0% done, 0/1033 completed, 7 in progress, 1019 pending, 7 failed. ❌ Failures for clang-tidy on /Users/matanl/Developer/engine/src/flutter/display_list/dl_blend_mode.cc: ../../flutter/display_list/dl_blend_mode.h:5:9: error: header guard does not follow preferred style [llvm-header-guard,-warnings-as-errors] 5 | #ifndef FLUTTER_DISPLAY_LIST_DL_BLEND_MODE_H_ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | USERS_MATANL_DEVELOPER_ENGINE_SRC_OUT_HOST_DEBUG_UNOPT_ARM64_______FLUTTER_DISPLAY_LIST_DL_BLEND_MODE_H 6 | #define FLUTTER_DISPLAY_LIST_DL_BLEND_MODE_H_ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | USERS_MATANL_DEVELOPER_ENGINE_SRC_OUT_HOST_DEBUG_UNOPT_ARM64_______FLUTTER_DISPLAY_LIST_DL_BLEND_MODE_H ^C ```
This will likely show failures on CI, so I'm following [our published directions](https://github.com/flutter/flutter/wiki/Engine-Clang-Tidy-Linter#clang-tidy-fix-on-ci) to get CI to tell me what needs to get fixed, and won't submit until there are no warnings at HEAD. As such, not seeking LGTM yet (draft). --------- Co-authored-by: Zachary Anderson --- engine/src/flutter/.clang-tidy | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/engine/src/flutter/.clang-tidy b/engine/src/flutter/.clang-tidy index b65d8f4336..0e68ce7e4b 100644 --- a/engine/src/flutter/.clang-tidy +++ b/engine/src/flutter/.clang-tidy @@ -39,3 +39,11 @@ CheckOptions: value: "lower_case" - key: readability-identifier-naming.PrivateMemberSuffix value: "_" + +# Lint headers within paths that contain "/flutter/" but not: +# - gen (generated code, the fact it compiles is good enough™) +# - third_party (we didn't author most of the code, and can't fix the lints) +# +# Note this is because of our buildroot setup, so the full path of a lint is: +# "../../flutter/impeller/core/runtime_types.h:1:1" as reported. +HeaderFilterRegex: "(!third_party/)(!gen/).*/flutter/.*"