From bb3881366b23c1d8598afa8900180f460b41c771 Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Wed, 19 Oct 2022 17:54:33 -0700 Subject: [PATCH] Only run clang-tidy warning checks reported as errors --- .clang-tidy | 20 +++----------------- tools/clang_tidy/lib/src/command.dart | 3 +-- tools/clang_tidy/test/clang_tidy_test.dart | 18 ++++++++++-------- 3 files changed, 14 insertions(+), 27 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index bbcce4fe1497e..2fc0e5cb81696 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -7,8 +7,11 @@ 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,\ @@ -16,23 +19,6 @@ readability-identifier-naming,\ 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 diff --git a/tools/clang_tidy/lib/src/command.dart b/tools/clang_tidy/lib/src/command.dart index 278d6da154b9c..f2132b2666934 100644 --- a/tools/clang_tidy/lib/src/command.dart +++ b/tools/clang_tidy/lib/src/command.dart @@ -134,8 +134,7 @@ class Command { WorkerJob createLintJob(Options options) { final List args = [ filePath, - if (options.warningsAsErrors != null) - '--warnings-as-errors=${options.warningsAsErrors}', + '--warnings-as-errors=${options.warningsAsErrors ?? '*'}', if (options.checks != null) options.checks!, if (options.fix) ...[ diff --git a/tools/clang_tidy/test/clang_tidy_test.dart b/tools/clang_tidy/test/clang_tidy_test.dart index 73129a0f99665..13b2e08188ae1 100644 --- a/tools/clang_tidy/test/clang_tidy_test.dart +++ b/tools/clang_tidy/test/clang_tidy_test.dart @@ -379,19 +379,21 @@ Future main(List 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 {