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

Only run clang-tidy warning checks reported as errors #36885

Merged
merged 1 commit into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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