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

Commit bb38813

Browse files
committed
Only run clang-tidy warning checks reported as errors
1 parent 9f7e3ae commit bb38813

File tree

3 files changed

+14
-27
lines changed

3 files changed

+14
-27
lines changed

.clang-tidy

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,18 @@ clang-diagnostic-*,\
77
google-*,\
88
modernize-use-default-member-init,\
99
readability-identifier-naming,\
10+
-google-build-using-namespace,\
11+
-google-default-arguments,\
1012
-google-objc-global-variable-declaration,\
1113
-google-objc-avoid-throwing-exception,\
14+
-google-readability-casting,\
1215
-clang-analyzer-nullability.NullPassedToNonnull,\
1316
-clang-analyzer-nullability.NullablePassedToNonnull,\
1417
-clang-analyzer-nullability.NullReturnedFromNonnull,\
1518
-clang-analyzer-nullability.NullableReturnedFromNonnull,\
1619
performance-move-const-arg,\
1720
performance-unnecessary-value-param"
1821

19-
# Only warnings treated as errors are reported
20-
# in the "ci/lint.sh" script and pre-push git hook.
21-
# Add checks when all warnings are fixed
22-
# to prevent new warnings being introduced.
23-
# https://github.com/flutter/flutter/issues/93279
24-
# Note: There are platform specific warnings as errors in
25-
# //ci/lint.sh
26-
WarningsAsErrors: "bugprone-use-after-move,\
27-
clang-analyzer-*,\
28-
readability-identifier-naming,\
29-
clang-diagnostic-*,\
30-
google-objc-*,\
31-
google-explicit-constructor,\
32-
google-readability-avoid-underscore-in-googletest-name,\
33-
performance-move-const-arg,\
34-
performance-unnecessary-value-param"
35-
3622
CheckOptions:
3723
- key: modernize-use-default-member-init.UseAssignment
3824
value: true

tools/clang_tidy/lib/src/command.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,7 @@ class Command {
134134
WorkerJob createLintJob(Options options) {
135135
final List<String> args = <String>[
136136
filePath,
137-
if (options.warningsAsErrors != null)
138-
'--warnings-as-errors=${options.warningsAsErrors}',
137+
'--warnings-as-errors=${options.warningsAsErrors ?? '*'}',
139138
if (options.checks != null)
140139
options.checks!,
141140
if (options.fix) ...<String>[

tools/clang_tidy/test/clang_tidy_test.dart

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -379,19 +379,21 @@ Future<int> main(List<String> args) async {
379379
final WorkerJob jobNoFix = command.createLintJob(noFixOptions);
380380
expect(jobNoFix.command[0], endsWith('../../buildtools/mac-x64/clang/bin/clang-tidy'));
381381
expect(jobNoFix.command[1], endsWith(filePath.replaceAll('/', io.Platform.pathSeparator)));
382-
expect(jobNoFix.command[2], '--');
383-
expect(jobNoFix.command[3], '');
384-
expect(jobNoFix.command[4], endsWith(filePath));
382+
expect(jobNoFix.command[2], '--warnings-as-errors=*');
383+
expect(jobNoFix.command[3], '--');
384+
expect(jobNoFix.command[4], '');
385+
expect(jobNoFix.command[5], endsWith(filePath));
385386

386387
final Options fixOptions = Options(buildCommandsPath: io.File('.'), fix: true);
387388
final WorkerJob jobWithFix = command.createLintJob(fixOptions);
388389
expect(jobWithFix.command[0], endsWith('../../buildtools/mac-x64/clang/bin/clang-tidy'));
389390
expect(jobWithFix.command[1], endsWith(filePath.replaceAll('/', io.Platform.pathSeparator)));
390-
expect(jobWithFix.command[2], '--fix');
391-
expect(jobWithFix.command[3], '--format-style=file');
392-
expect(jobWithFix.command[4], '--');
393-
expect(jobWithFix.command[5], '');
394-
expect(jobWithFix.command[6], endsWith(filePath));
391+
expect(jobWithFix.command[2], '--warnings-as-errors=*');
392+
expect(jobWithFix.command[3], '--fix');
393+
expect(jobWithFix.command[4], '--format-style=file');
394+
expect(jobWithFix.command[5], '--');
395+
expect(jobWithFix.command[6], '');
396+
expect(jobWithFix.command[7], endsWith(filePath));
395397
});
396398

397399
test('Command getLintAction flags third_party files', () async {

0 commit comments

Comments
 (0)