diff --git a/dwds/analysis_options.yaml b/dwds/analysis_options.yaml index af2eb6bc7..a7786007a 100644 --- a/dwds/analysis_options.yaml +++ b/dwds/analysis_options.yaml @@ -20,3 +20,4 @@ linter: - prefer_final_locals - unawaited_futures - avoid_void_async + - unnecessary_lambdas diff --git a/dwds/debug_extension_mv3/web/settings.dart b/dwds/debug_extension_mv3/web/settings.dart index aa49d75c5..d6af1b810 100644 --- a/dwds/debug_extension_mv3/web/settings.dart +++ b/dwds/debug_extension_mv3/web/settings.dart @@ -48,9 +48,7 @@ void _showSavedMsg() { final snackbar = document.getElementById('savedSnackbar'); if (snackbar == null) return; snackbar.classes.add('show'); - Timer(Duration(seconds: 3), () { - _maybeHideSavedMsg(); - }); + Timer(Duration(seconds: 3), _maybeHideSavedMsg); } void _maybeHideSavedMsg() { diff --git a/dwds/debug_extension_mv3/web/utils.dart b/dwds/debug_extension_mv3/web/utils.dart index 1f7aef1ae..fe33b659f 100644 --- a/dwds/debug_extension_mv3/web/utils.dart +++ b/dwds/debug_extension_mv3/web/utils.dart @@ -30,11 +30,7 @@ Future createTab(String url, {bool inNewWindow = false}) { active: true, url: url, ), - allowInterop( - (Tab tab) { - completer.complete(tab); - }, - ), + allowInterop(completer.complete), ); } return completer.future; @@ -42,9 +38,7 @@ Future createTab(String url, {bool inNewWindow = false}) { Future getTab(int tabId) { final completer = Completer(); - chrome.tabs.get(tabId, allowInterop((tab) { - completer.complete(tab); - })); + chrome.tabs.get(tabId, allowInterop(completer.complete)); return completer.future; } diff --git a/dwds/lib/src/debugging/location.dart b/dwds/lib/src/debugging/location.dart index 217dc3c4e..ffaced033 100644 --- a/dwds/lib/src/debugging/location.dart +++ b/dwds/lib/src/debugging/location.dart @@ -271,8 +271,7 @@ class Locations { /// /// This will populate the [_sourceToLocation] and [_moduleToLocations] maps. Future> _locationsForModule(String module) async { - final memoizer = - _locationMemoizer.putIfAbsent(module, () => AsyncMemoizer()); + final memoizer = _locationMemoizer.putIfAbsent(module, AsyncMemoizer.new); return await memoizer.runOnce(() async { if (_moduleToLocations.containsKey(module)) { diff --git a/dwds/lib/src/handlers/dev_handler.dart b/dwds/lib/src/handlers/dev_handler.dart index c4db774f3..6b44b2524 100644 --- a/dwds/lib/src/handlers/dev_handler.dart +++ b/dwds/lib/src/handlers/dev_handler.dart @@ -160,7 +160,7 @@ class DevHandler { .takeUntilGap(const Duration(milliseconds: 50)); // We enqueue this work as we need to begin listening (`.hasNext`) // before events are received. - safeUnawaited(Future.microtask(() => connection.runtime.enable())); + safeUnawaited(Future.microtask(connection.runtime.enable)); await for (var contextId in contextIds) { final result = await connection.sendCommand('Runtime.evaluate', { diff --git a/dwds/lib/src/services/chrome_proxy_service.dart b/dwds/lib/src/services/chrome_proxy_service.dart index 63fa47199..8d07b5ff6 100644 --- a/dwds/lib/src/services/chrome_proxy_service.dart +++ b/dwds/lib/src/services/chrome_proxy_service.dart @@ -118,7 +118,7 @@ class ChromeProxyService implements VmServiceInterface { _skipLists, root, ); - debugger.then((value) => _debuggerCompleter.complete(value)); + debugger.then(_debuggerCompleter.complete); } static Future create( diff --git a/dwds/test/extension_debugger_test.dart b/dwds/test/extension_debugger_test.dart index a62ef83e5..b02257c85 100644 --- a/dwds/test/extension_debugger_test.dart +++ b/dwds/test/extension_debugger_test.dart @@ -40,9 +40,7 @@ void main() async { ..success = true); final resultCompleter = Completer(); unawaited(extensionDebugger.sendCommand('Runtime.evaluate', - params: {'expression': '\$pi'}).then((response) { - resultCompleter.complete(response); - })); + params: {'expression': '\$pi'}).then(resultCompleter.complete)); connection.controllerIncoming.sink .add(jsonEncode(serializers.serialize(extensionResponse))); final response = await resultCompleter.future; diff --git a/dwds/test/fixtures/debugger_data.dart b/dwds/test/fixtures/debugger_data.dart index 5577acc1f..f702cab88 100644 --- a/dwds/test/fixtures/debugger_data.dart +++ b/dwds/test/fixtures/debugger_data.dart @@ -11,8 +11,7 @@ import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart'; /// /// This is taken from a real run, but truncated to two levels of scope and one /// level of stack. -List frames1 = - frames1Json.map((json) => WipCallFrame(json)).toList(); +List frames1 = frames1Json.map(WipCallFrame.new).toList(); List> frames1Json = [ { diff --git a/dwds/test/instances/instance_inspection_common.dart b/dwds/test/instances/instance_inspection_common.dart index 9711283db..03fa55681 100644 --- a/dwds/test/instances/instance_inspection_common.dart +++ b/dwds/test/instances/instance_inspection_common.dart @@ -140,7 +140,7 @@ Matcher matchPrimitiveInstance( {required String kind, required dynamic value}) => isA() .having((e) => e.kind, 'kind', kind) - .having((e) => _getValue(e), 'value', value); + .having(_getValue, 'value', value); Matcher matchPlainInstance({required String type}) => isA() .having((e) => e.kind, 'kind', InstanceKind.kPlainInstance) diff --git a/dwds/test/sdk_configuration_test.dart b/dwds/test/sdk_configuration_test.dart index 22ae6023f..89b2abe55 100644 --- a/dwds/test/sdk_configuration_test.dart +++ b/dwds/test/sdk_configuration_test.dart @@ -26,9 +26,8 @@ void main() { test('Cannot validate an empty configuration layout', () async { final emptyConfiguration = SdkConfiguration.empty(); - expect(() => emptyConfiguration.validateSdkDir(), - _throwsDoesNotExistException); - expect(() => emptyConfiguration.validate(), _throwsDoesNotExistException); + expect(emptyConfiguration.validateSdkDir, _throwsDoesNotExistException); + expect(emptyConfiguration.validate, _throwsDoesNotExistException); }); }); @@ -85,7 +84,7 @@ void main() { final sdkConfiguration = TestSdkLayout.createConfiguration(sdkLayout); sdkConfiguration.validateSdkDir(); - expect(() => sdkConfiguration.validate(), _throwsDoesNotExistException); + expect(sdkConfiguration.validate, _throwsDoesNotExistException); }); }); diff --git a/dwds/web/promise.dart b/dwds/web/promise.dart index 30e76e4eb..fdc2d4d57 100644 --- a/dwds/web/promise.dart +++ b/dwds/web/promise.dart @@ -47,7 +47,8 @@ Future toFuture(Promise promise) { final completer = Completer(); promise.then( allowInterop(completer.complete), - allowInterop((e) => completer.completeError(e)), + // TODO(annagrin): propagate stack trace from promise instead. + allowInterop((e) => completer.completeError(e, StackTrace.current)), ); return completer.future; } diff --git a/dwds/web/reloader/require_restarter.dart b/dwds/web/reloader/require_restarter.dart index 6124c551e..558925c5a 100644 --- a/dwds/web/reloader/require_restarter.dart +++ b/dwds/web/reloader/require_restarter.dart @@ -221,9 +221,7 @@ class RequireRestarter implements Restarter { final stackTrace = StackTrace.current; requireLoader.forceLoadModule( moduleId, - allowInterop(() { - completer.complete(); - }), + allowInterop(completer.complete), allowInterop((e) { completer.completeError( HotReloadFailedException(e.message), stackTrace); diff --git a/dwds/web/run_main.dart b/dwds/web/run_main.dart index bee8731d5..23f490ebf 100644 --- a/dwds/web/run_main.dart +++ b/dwds/web/run_main.dart @@ -9,7 +9,7 @@ import 'dart:html'; /// More specifically, the script has the correct `nonce` value set. final ScriptElement Function() _createScript = (() { final nonce = _findNonce(); - if (nonce == null) return () => ScriptElement(); + if (nonce == null) return ScriptElement.new; return () => ScriptElement()..setAttribute('nonce', nonce); })();