Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit e7d7eda

Browse files
authored
clang-tidy: Added an environment variable that allows fix to print the (#37024)
generated diff.
1 parent 55ed37f commit e7d7eda

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

ci/lint.sh

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@ DART="${DART_BIN}/dart"
3636
# to have this as an error.
3737
MAC_HOST_WARNINGS_AS_ERRORS="performance-move-const-arg,performance-unnecessary-value-param"
3838

39+
# FLUTTER_LINT_PRINT_FIX will make it so that fix is executed and the generated
40+
# diff is printed to stdout if clang-tidy fails. This is helpful for enabling
41+
# new lints.
42+
if [[ -z "${FLUTTER_LINT_PRINT_FIX}" ]]; then
43+
fix_flag=""
44+
else
45+
fix_flag="--fix"
46+
fi
47+
3948
COMPILE_COMMANDS="$SRC_DIR/out/host_debug/compile_commands.json"
4049
if [ ! -f "$COMPILE_COMMANDS" ]; then
4150
(cd "$SRC_DIR"; ./flutter/tools/gn)
@@ -49,7 +58,18 @@ cd "$SCRIPT_DIR"
4958
"$SRC_DIR/flutter/tools/clang_tidy/bin/main.dart" \
5059
--src-dir="$SRC_DIR" \
5160
--mac-host-warnings-as-errors="$MAC_HOST_WARNINGS_AS_ERRORS" \
52-
"$@"
61+
$fix_flag \
62+
"$@" && true # errors ignored
63+
clang_tidy_return=$?
64+
if [ $clang_tidy_return -ne 0 ]; then
65+
if [ -n "$fix_flag" ]; then
66+
echo "###################################################"
67+
echo "# Attempted to fix issues with the following patch:"
68+
echo "###################################################"
69+
git --no-pager diff
70+
fi
71+
exit $clang_tidy_return
72+
fi
5373

5474
echo "$(date +%T) Running pylint"
5575

0 commit comments

Comments
 (0)