From c47de9e8be551705a4d3e4e06289914fb8ed4f75 Mon Sep 17 00:00:00 2001 From: gaaclarke <30870216+gaaclarke@users.noreply.github.com> Date: Mon, 7 Nov 2022 14:40:53 -0800 Subject: [PATCH] clang-tidy: Added an environment variable that allows fix to print the (flutter/engine#37024) generated diff. --- engine/src/flutter/ci/lint.sh | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/engine/src/flutter/ci/lint.sh b/engine/src/flutter/ci/lint.sh index 00e31b8525..e5096b3518 100755 --- a/engine/src/flutter/ci/lint.sh +++ b/engine/src/flutter/ci/lint.sh @@ -36,6 +36,15 @@ DART="${DART_BIN}/dart" # to have this as an error. MAC_HOST_WARNINGS_AS_ERRORS="performance-move-const-arg,performance-unnecessary-value-param" +# FLUTTER_LINT_PRINT_FIX will make it so that fix is executed and the generated +# diff is printed to stdout if clang-tidy fails. This is helpful for enabling +# new lints. +if [[ -z "${FLUTTER_LINT_PRINT_FIX}" ]]; then + fix_flag="" +else + fix_flag="--fix" +fi + COMPILE_COMMANDS="$SRC_DIR/out/host_debug/compile_commands.json" if [ ! -f "$COMPILE_COMMANDS" ]; then (cd "$SRC_DIR"; ./flutter/tools/gn) @@ -49,7 +58,18 @@ cd "$SCRIPT_DIR" "$SRC_DIR/flutter/tools/clang_tidy/bin/main.dart" \ --src-dir="$SRC_DIR" \ --mac-host-warnings-as-errors="$MAC_HOST_WARNINGS_AS_ERRORS" \ - "$@" + $fix_flag \ + "$@" && true # errors ignored +clang_tidy_return=$? +if [ $clang_tidy_return -ne 0 ]; then + if [ -n "$fix_flag" ]; then + echo "###################################################" + echo "# Attempted to fix issues with the following patch:" + echo "###################################################" + git --no-pager diff + fi + exit $clang_tidy_return +fi echo "$(date +%T) Running pylint"