[go: nahoru, domu]

Skip to content

Commit

Permalink
Only run clang-tidy warning checks reported as errors (flutter#36885)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmagman committed Nov 18, 2022
1 parent 80b25a3 commit 1f4ddc3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 27 deletions.
20 changes: 3 additions & 17 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,18 @@ clang-diagnostic-*,\
google-*,\
modernize-use-default-member-init,\
readability-identifier-naming,\
-google-build-using-namespace,\
-google-default-arguments,\
-google-objc-global-variable-declaration,\
-google-objc-avoid-throwing-exception,\
-google-readability-casting,\
-clang-analyzer-nullability.NullPassedToNonnull,\
-clang-analyzer-nullability.NullablePassedToNonnull,\
-clang-analyzer-nullability.NullReturnedFromNonnull,\
-clang-analyzer-nullability.NullableReturnedFromNonnull,\
performance-move-const-arg,\
performance-unnecessary-value-param"

# Only warnings treated as errors are reported
# in the "ci/lint.sh" script and pre-push git hook.
# Add checks when all warnings are fixed
# to prevent new warnings being introduced.
# https://github.com/flutter/flutter/issues/93279
# Note: There are platform specific warnings as errors in
# //ci/lint.sh
WarningsAsErrors: "bugprone-use-after-move,\
clang-analyzer-*,\
readability-identifier-naming,\
clang-diagnostic-*,\
google-objc-*,\
google-explicit-constructor,\
google-readability-avoid-underscore-in-googletest-name,\
performance-move-const-arg,\
performance-unnecessary-value-param"

CheckOptions:
- key: modernize-use-default-member-init.UseAssignment
value: true
Expand Down
3 changes: 1 addition & 2 deletions tools/clang_tidy/lib/src/command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,7 @@ class Command {
WorkerJob createLintJob(Options options) {
final List<String> args = <String>[
filePath,
if (options.warningsAsErrors != null)
'--warnings-as-errors=${options.warningsAsErrors}',
'--warnings-as-errors=${options.warningsAsErrors ?? '*'}',
if (options.checks != null)
options.checks!,
if (options.fix) ...<String>[
Expand Down
18 changes: 10 additions & 8 deletions tools/clang_tidy/test/clang_tidy_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -379,19 +379,21 @@ Future<int> main(List<String> args) async {
final WorkerJob jobNoFix = command.createLintJob(noFixOptions);
expect(jobNoFix.command[0], endsWith('../../buildtools/mac-x64/clang/bin/clang-tidy'));
expect(jobNoFix.command[1], endsWith(filePath.replaceAll('/', io.Platform.pathSeparator)));
expect(jobNoFix.command[2], '--');
expect(jobNoFix.command[3], '');
expect(jobNoFix.command[4], endsWith(filePath));
expect(jobNoFix.command[2], '--warnings-as-errors=*');
expect(jobNoFix.command[3], '--');
expect(jobNoFix.command[4], '');
expect(jobNoFix.command[5], endsWith(filePath));

final Options fixOptions = Options(buildCommandsPath: io.File('.'), fix: true);
final WorkerJob jobWithFix = command.createLintJob(fixOptions);
expect(jobWithFix.command[0], endsWith('../../buildtools/mac-x64/clang/bin/clang-tidy'));
expect(jobWithFix.command[1], endsWith(filePath.replaceAll('/', io.Platform.pathSeparator)));
expect(jobWithFix.command[2], '--fix');
expect(jobWithFix.command[3], '--format-style=file');
expect(jobWithFix.command[4], '--');
expect(jobWithFix.command[5], '');
expect(jobWithFix.command[6], endsWith(filePath));
expect(jobWithFix.command[2], '--warnings-as-errors=*');
expect(jobWithFix.command[3], '--fix');
expect(jobWithFix.command[4], '--format-style=file');
expect(jobWithFix.command[5], '--');
expect(jobWithFix.command[6], '');
expect(jobWithFix.command[7], endsWith(filePath));
});

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

0 comments on commit 1f4ddc3

Please sign in to comment.