Skip to content

Commit a942b5f

Browse files
author
Anna Gringauze
authored
Add unnecessary_lambdas lint (#1978)
* Validate only needed summaries in expression_compiler_service * Add avoid_void_async lint * Add unnecessary_lambdas lint
1 parent 3774cf8 commit a942b5f

File tree

13 files changed

+17
-30
lines changed

13 files changed

+17
-30
lines changed

dwds/analysis_options.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ linter:
2020
- prefer_final_locals
2121
- unawaited_futures
2222
- avoid_void_async
23+
- unnecessary_lambdas

dwds/debug_extension_mv3/web/settings.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@ void _showSavedMsg() {
4848
final snackbar = document.getElementById('savedSnackbar');
4949
if (snackbar == null) return;
5050
snackbar.classes.add('show');
51-
Timer(Duration(seconds: 3), () {
52-
_maybeHideSavedMsg();
53-
});
51+
Timer(Duration(seconds: 3), _maybeHideSavedMsg);
5452
}
5553

5654
void _maybeHideSavedMsg() {

dwds/debug_extension_mv3/web/utils.dart

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,15 @@ Future<Tab> createTab(String url, {bool inNewWindow = false}) {
3030
active: true,
3131
url: url,
3232
),
33-
allowInterop(
34-
(Tab tab) {
35-
completer.complete(tab);
36-
},
37-
),
33+
allowInterop(completer.complete),
3834
);
3935
}
4036
return completer.future;
4137
}
4238

4339
Future<Tab?> getTab(int tabId) {
4440
final completer = Completer<Tab?>();
45-
chrome.tabs.get(tabId, allowInterop((tab) {
46-
completer.complete(tab);
47-
}));
41+
chrome.tabs.get(tabId, allowInterop(completer.complete));
4842
return completer.future;
4943
}
5044

dwds/lib/src/debugging/location.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,7 @@ class Locations {
271271
///
272272
/// This will populate the [_sourceToLocation] and [_moduleToLocations] maps.
273273
Future<Set<Location>> _locationsForModule(String module) async {
274-
final memoizer =
275-
_locationMemoizer.putIfAbsent(module, () => AsyncMemoizer());
274+
final memoizer = _locationMemoizer.putIfAbsent(module, AsyncMemoizer.new);
276275

277276
return await memoizer.runOnce(() async {
278277
if (_moduleToLocations.containsKey(module)) {

dwds/lib/src/handlers/dev_handler.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ class DevHandler {
160160
.takeUntilGap(const Duration(milliseconds: 50));
161161
// We enqueue this work as we need to begin listening (`.hasNext`)
162162
// before events are received.
163-
safeUnawaited(Future.microtask(() => connection.runtime.enable()));
163+
safeUnawaited(Future.microtask(connection.runtime.enable));
164164

165165
await for (var contextId in contextIds) {
166166
final result = await connection.sendCommand('Runtime.evaluate', {

dwds/lib/src/services/chrome_proxy_service.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class ChromeProxyService implements VmServiceInterface {
118118
_skipLists,
119119
root,
120120
);
121-
debugger.then((value) => _debuggerCompleter.complete(value));
121+
debugger.then(_debuggerCompleter.complete);
122122
}
123123

124124
static Future<ChromeProxyService> create(

dwds/test/extension_debugger_test.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ void main() async {
4040
..success = true);
4141
final resultCompleter = Completer();
4242
unawaited(extensionDebugger.sendCommand('Runtime.evaluate',
43-
params: {'expression': '\$pi'}).then((response) {
44-
resultCompleter.complete(response);
45-
}));
43+
params: {'expression': '\$pi'}).then(resultCompleter.complete));
4644
connection.controllerIncoming.sink
4745
.add(jsonEncode(serializers.serialize(extensionResponse)));
4846
final response = await resultCompleter.future;

dwds/test/fixtures/debugger_data.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart';
1111
///
1212
/// This is taken from a real run, but truncated to two levels of scope and one
1313
/// level of stack.
14-
List<WipCallFrame> frames1 =
15-
frames1Json.map((json) => WipCallFrame(json)).toList();
14+
List<WipCallFrame> frames1 = frames1Json.map(WipCallFrame.new).toList();
1615

1716
List<Map<String, dynamic>> frames1Json = [
1817
{

dwds/test/instances/instance_inspection_common.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ Matcher matchPrimitiveInstance(
140140
{required String kind, required dynamic value}) =>
141141
isA<Instance>()
142142
.having((e) => e.kind, 'kind', kind)
143-
.having((e) => _getValue(e), 'value', value);
143+
.having(_getValue, 'value', value);
144144

145145
Matcher matchPlainInstance({required String type}) => isA<Instance>()
146146
.having((e) => e.kind, 'kind', InstanceKind.kPlainInstance)

dwds/test/sdk_configuration_test.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ void main() {
2626

2727
test('Cannot validate an empty configuration layout', () async {
2828
final emptyConfiguration = SdkConfiguration.empty();
29-
expect(() => emptyConfiguration.validateSdkDir(),
30-
_throwsDoesNotExistException);
31-
expect(() => emptyConfiguration.validate(), _throwsDoesNotExistException);
29+
expect(emptyConfiguration.validateSdkDir, _throwsDoesNotExistException);
30+
expect(emptyConfiguration.validate, _throwsDoesNotExistException);
3231
});
3332
});
3433

@@ -85,7 +84,7 @@ void main() {
8584
final sdkConfiguration = TestSdkLayout.createConfiguration(sdkLayout);
8685

8786
sdkConfiguration.validateSdkDir();
88-
expect(() => sdkConfiguration.validate(), _throwsDoesNotExistException);
87+
expect(sdkConfiguration.validate, _throwsDoesNotExistException);
8988
});
9089
});
9190

0 commit comments

Comments
 (0)