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

Commit 1b32c5d

Browse files
committed
clang-tidy: Added an environment variable that allows fix to print the
generated diff.
1 parent 45fe7b9 commit 1b32c5d

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

ci/lint.sh

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ 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+
if [[ -z "${FLUTTER_LINT_PRINT_FIX}" ]]; then
40+
fix_flag=""
41+
else
42+
fix_flag="--fix"
43+
fi
44+
3945
COMPILE_COMMANDS="$SRC_DIR/out/host_debug/compile_commands.json"
4046
if [ ! -f "$COMPILE_COMMANDS" ]; then
4147
(cd "$SRC_DIR"; ./flutter/tools/gn)
@@ -47,7 +53,18 @@ cd "$SCRIPT_DIR"
4753
"$SRC_DIR/flutter/tools/clang_tidy/bin/main.dart" \
4854
--src-dir="$SRC_DIR" \
4955
--mac-host-warnings-as-errors="$MAC_HOST_WARNINGS_AS_ERRORS" \
50-
"$@"
56+
$fix_flag \
57+
"$@" && true # errors ignored
58+
clang_tidy_return=$?
59+
if [ $clang_tidy_return -ne 0 ]; then
60+
if [ -n "$fix_flag" ]; then
61+
echo "###################################################"
62+
echo "# Attempted to fix issues with the following patch:"
63+
echo "###################################################"
64+
git --no-pager diff
65+
fi
66+
exit $clang_tidy_return
67+
fi
5168

5269
cd "$FLUTTER_DIR"
5370
pylint-2.7 --rcfile=.pylintrc \

0 commit comments

Comments
 (0)