From 79b5e5bc8af7d9df3374dfe6141653848d1c03ac Mon Sep 17 00:00:00 2001 From: Alexandre Ardhuin Date: Mon, 19 Nov 2018 10:37:55 +0100 Subject: [PATCH] Add missing lints (#24381) * update lint list * enable sort_pub_dependencies * enable avoid_returning_null_for_void * enable flutter_style_todos --- analysis_options.yaml | 5 +++++ packages/flutter/lib/src/widgets/widget_inspector.dart | 7 ++++--- packages/flutter/test/foundation/diagnostics_test.dart | 6 +++--- packages/flutter_tools/bin/fuchsia_tester.dart | 2 +- packages/flutter_tools/lib/src/commands/run.dart | 2 +- .../flutter_tools/lib/src/commands/update_packages.dart | 2 ++ packages/flutter_tools/lib/src/ios/mac.dart | 6 +++--- packages/flutter_tools/lib/src/run_cold.dart | 2 +- packages/flutter_tools/lib/src/run_hot.dart | 2 +- packages/flutter_tools/lib/src/vmservice.dart | 2 +- 10 files changed, 22 insertions(+), 14 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 5d8ab35511..8957dfe03b 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -56,6 +56,7 @@ linter: - avoid_empty_else - avoid_field_initializers_in_const_classes - avoid_function_literals_in_foreach_calls + # - avoid_implementing_value_types # not yet tested - avoid_init_to_null # - avoid_js_rounded_ints # only useful when targeting JS runtime - avoid_null_checks_in_equality_operators @@ -65,6 +66,7 @@ linter: - avoid_renaming_method_parameters - avoid_return_types_on_setters # - avoid_returning_null # there are plenty of valid reasons to return null + - avoid_returning_null_for_void # - avoid_returning_this # there are plenty of valid reasons to return this # - avoid_setters_without_getters # not yet tested # - avoid_single_cascade_in_expression_statements # not yet tested @@ -87,6 +89,7 @@ linter: - empty_constructor_bodies - empty_statements # - file_names # not yet tested + - flutter_style_todos - hash_and_equals - implementation_imports # - invariant_booleans # too many false positives: https://github.com/dart-lang/linter/issues/811 @@ -128,6 +131,7 @@ linter: # - prefer_function_declarations_over_variables # not yet tested - prefer_generic_function_type_aliases - prefer_initializing_formals + # - prefer_int_literals # not yet tested # - prefer_interpolation_to_compose_strings # not yet tested - prefer_is_empty - prefer_is_not_empty @@ -140,6 +144,7 @@ linter: - recursive_getters - slash_for_doc_comments - sort_constructors_first + - sort_pub_dependencies - sort_unnamed_constructors_first - super_goes_last - test_types_in_equals diff --git a/packages/flutter/lib/src/widgets/widget_inspector.dart b/packages/flutter/lib/src/widgets/widget_inspector.dart index 54d62ebd04..6ecfc4084d 100644 --- a/packages/flutter/lib/src/widgets/widget_inspector.dart +++ b/packages/flutter/lib/src/widgets/widget_inspector.dart @@ -970,7 +970,7 @@ mixin WidgetInspectorService { getter: () async => _trackRebuildDirtyWidgets, setter: (bool value) async { if (value == _trackRebuildDirtyWidgets) { - return null; + return; } _rebuildStats.resetCounts(); _trackRebuildDirtyWidgets = value; @@ -979,10 +979,11 @@ mixin WidgetInspectorService { debugOnRebuildDirtyWidget = _onRebuildWidget; // Trigger a rebuild so there are baseline stats for rebuilds // performed by the app. - return forceRebuild(); + await forceRebuild(); + return; } else { debugOnRebuildDirtyWidget = null; - return null; + return; } }, ); diff --git a/packages/flutter/test/foundation/diagnostics_test.dart b/packages/flutter/test/foundation/diagnostics_test.dart index d19511f130..e49b0c5cae 100644 --- a/packages/flutter/test/foundation/diagnostics_test.dart +++ b/packages/flutter/test/foundation/diagnostics_test.dart @@ -563,10 +563,10 @@ void main() { golden: 'TestTree#00000(stringProperty1: value1, doubleProperty1: 42.5, roundedProperty: 0.3, nullProperty: null, )', ); + // TODO(jacobr): this is an ugly test case. // There isn't anything interesting for this case as the children look the - // same with and without children. TODO(jacobr): this is an ugly test case. - // only difference is odd not clearly desirable density of B3 being right - // next to node C. + // same with and without children. Only difference is odd not clearly + // desirable density of B3 being right next to node C. goldenStyleTest( 'single line last child', style: DiagnosticsTreeStyle.sparse, diff --git a/packages/flutter_tools/bin/fuchsia_tester.dart b/packages/flutter_tools/bin/fuchsia_tester.dart index a5e0ee32e7..a6d0e8eb43 100644 --- a/packages/flutter_tools/bin/fuchsia_tester.dart +++ b/packages/flutter_tools/bin/fuchsia_tester.dart @@ -97,7 +97,7 @@ Future run(List args) async { } // Put the tester shell where runTests expects it. - // TODO(tvolkert,garymm): Switch to a Fuchsia-specific Artifacts impl. + // TODO(garymm): Switch to a Fuchsia-specific Artifacts impl. final Link testerDestLink = fs.link(artifacts.getArtifactPath(Artifact.flutterTester)); testerDestLink.parent.createSync(recursive: true); diff --git a/packages/flutter_tools/lib/src/commands/run.dart b/packages/flutter_tools/lib/src/commands/run.dart index 145e6680c9..cb2efb9625 100644 --- a/packages/flutter_tools/lib/src/commands/run.dart +++ b/packages/flutter_tools/lib/src/commands/run.dart @@ -19,7 +19,7 @@ import '../run_hot.dart'; import '../runner/flutter_command.dart'; import 'daemon.dart'; -// TODO(flutter/flutter#23031): Test this. +// TODO(mklim): Test this, flutter/flutter#23031. abstract class RunCommandBase extends FlutterCommand { // Used by run and drive commands. RunCommandBase({ bool verboseHelp = false }) { diff --git a/packages/flutter_tools/lib/src/commands/update_packages.dart b/packages/flutter_tools/lib/src/commands/update_packages.dart index 54594dde17..b0e6cadee8 100644 --- a/packages/flutter_tools/lib/src/commands/update_packages.dart +++ b/packages/flutter_tools/lib/src/commands/update_packages.dart @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// ignore_for_file: flutter_style_todos + import 'dart:async'; import 'dart:collection'; diff --git a/packages/flutter_tools/lib/src/ios/mac.dart b/packages/flutter_tools/lib/src/ios/mac.dart index bfa1247979..1847f7808c 100644 --- a/packages/flutter_tools/lib/src/ios/mac.dart +++ b/packages/flutter_tools/lib/src/ios/mac.dart @@ -297,7 +297,7 @@ Future buildXcodeProject({ if (!_checkXcodeVersion()) return XcodeBuildResult(success: false); - // TODO(cbracken) remove when https://github.com/flutter/flutter/issues/20685 is fixed. + // TODO(cbracken): remove when https://github.com/flutter/flutter/issues/20685 is fixed. await setXcodeWorkspaceBuildSystem( workspaceDirectory: app.project.xcodeWorkspace, workspaceSettings: app.project.xcodeWorkspaceSharedSettings, @@ -458,7 +458,7 @@ Future buildXcodeProject({ if (line == 'all done') { // Free pipe file. tempDir?.deleteSync(recursive: true); - return null; + return; } } else { initialBuildStatus.cancel(); @@ -469,7 +469,7 @@ Future buildXcodeProject({ ); } } - return listenToScriptOutputLine(); + await listenToScriptOutputLine(); } // Trigger the start of the pipe -> stdout loop. Ignore exceptions. diff --git a/packages/flutter_tools/lib/src/run_cold.dart b/packages/flutter_tools/lib/src/run_cold.dart index 9d301de29f..12e3478dd7 100644 --- a/packages/flutter_tools/lib/src/run_cold.dart +++ b/packages/flutter_tools/lib/src/run_cold.dart @@ -12,7 +12,7 @@ import 'globals.dart'; import 'resident_runner.dart'; import 'tracing.dart'; -// TODO(flutter/flutter#23031): Test this. +// TODO(mklim): Test this, flutter/flutter#23031. class ColdRunner extends ResidentRunner { ColdRunner( List devices, { diff --git a/packages/flutter_tools/lib/src/run_hot.dart b/packages/flutter_tools/lib/src/run_hot.dart index ded7a25649..07484de3a6 100644 --- a/packages/flutter_tools/lib/src/run_hot.dart +++ b/packages/flutter_tools/lib/src/run_hot.dart @@ -48,7 +48,7 @@ class DeviceReloadReport { List> reports; // List has one report per Flutter view. } -// TODO(flutter/flutter#23031): Test this. +// TODO(mklim): Test this, flutter/flutter#23031. class HotRunner extends ResidentRunner { HotRunner( List devices, { diff --git a/packages/flutter_tools/lib/src/vmservice.dart b/packages/flutter_tools/lib/src/vmservice.dart index 633fc9d388..4e355bf7a7 100644 --- a/packages/flutter_tools/lib/src/vmservice.dart +++ b/packages/flutter_tools/lib/src/vmservice.dart @@ -102,7 +102,7 @@ const Duration kLongRequestTimeout = Duration(minutes: 1); /// Used for RPC requests that should never take a long time. const Duration kShortRequestTimeout = Duration(seconds: 5); -// TODO(flutter/flutter#23031): Test this. +// TODO(mklim): Test this, flutter/flutter#23031. /// A connection to the Dart VM Service. class VMService { VMService(