Skip to content

Commit b234db9

Browse files
kevmooelliette
authored andcommitted
Enable pkg:lints recommended lints (dart-lang#1444)
1 parent c4cf507 commit b234db9

File tree

14 files changed

+26
-24
lines changed

14 files changed

+26
-24
lines changed

analysis_options.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ linter:
4040
- empty_catches
4141
- empty_constructor_bodies
4242
- empty_statements
43+
- exhaustive_cases
4344
- file_names
4445
- hash_and_equals
4546
- implementation_imports
@@ -66,18 +67,23 @@ linter:
6667
- prefer_equal_for_default_values
6768
- prefer_final_fields
6869
- prefer_for_elements_to_map_fromIterable
70+
- prefer_function_declarations_over_variables
6971
- prefer_generic_function_type_aliases
7072
- prefer_if_null_operators
7173
- prefer_initializing_formals
74+
- prefer_inlined_adds
7275
- prefer_interpolation_to_compose_strings
7376
- prefer_is_empty
7477
- prefer_is_not_empty
78+
- prefer_is_not_operator
7579
- prefer_iterable_whereType
7680
- prefer_null_aware_operators
7781
- prefer_relative_imports
7882
- prefer_single_quotes
7983
- prefer_spread_collections
8084
- prefer_typing_uninitialized_variables
85+
- prefer_void_to_null
86+
- provide_deprecation_message
8187
- recursive_getters
8288
- slash_for_doc_comments
8389
- test_types_in_equals
@@ -91,8 +97,11 @@ linter:
9197
- unnecessary_new
9298
- unnecessary_null_aware_assignments
9399
- unnecessary_null_in_if_null_operators
100+
- unnecessary_overrides
94101
- unnecessary_parenthesis
95102
- unnecessary_statements
103+
- unnecessary_string_escapes
104+
- unnecessary_string_interpolations
96105
- unnecessary_this
97106
- unrelated_type_equality_checks
98107
- use_function_type_syntax_for_parameters

dwds/lib/src/debugging/debugger.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ class Debugger extends Domain {
181181
return debugger;
182182
}
183183

184-
Future<Null> _initialize() async {
184+
Future<void> _initialize() async {
185185
// We must add a listener before enabling the debugger otherwise we will
186186
// miss events.
187187
// Allow a null debugger/connection for unit tests.

dwds/lib/src/debugging/inspector.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ class AppInspector extends Domain {
140140
isolateFlags: [])
141141
..extensionRPCs = [];
142142
AppInspector appInspector;
143-
var provider = () => appInspector;
143+
AppInspector provider() => appInspector;
144144
var libraryHelper = LibraryHelper(provider);
145145
var classHelper = ClassHelper(provider);
146146
var instanceHelper = InstanceHelper(provider);

dwds/lib/src/handlers/injector.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class DwdsInjector {
8282
var requestedUri = request.requestedUri;
8383
var appId = base64
8484
.encode(md5.convert(utf8.encode('$requestedUri')).bytes);
85-
var scheme = '${request.requestedUri.scheme}';
85+
var scheme = request.requestedUri.scheme;
8686
if (!_useSseForInjectedClient) {
8787
// Switch http->ws and https->wss.
8888
scheme = scheme.replaceFirst('http', 'ws');

dwds/lib/src/services/debug_service.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ class DebugService {
154154
scheme: 'http',
155155
host: hostname,
156156
port: port,
157-
path: '$authToken',
157+
path: authToken,
158158
),
159159
serviceUri: Uri(
160160
scheme: 'http',
@@ -180,7 +180,7 @@ class DebugService {
180180
scheme: 'ws',
181181
host: hostname,
182182
port: port,
183-
path: '$authToken',
183+
path: authToken,
184184
))
185185
.toString();
186186
}

dwds/lib/src/utilities/conversions.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
// @dart = 2.9
66

77
/// Functions for converting between the different object references we use.
8-
98
import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart';
109

1110
/// Convert [argument] to a form usable in WIP evaluation calls.
@@ -81,7 +80,7 @@ RemoteObject remoteObjectFor(String dartId) {
8180
/// RemoteObjects.
8281
String dartIdFor(Object argument) {
8382
if (argument == null) {
84-
return '$_nullId';
83+
return _nullId;
8584
}
8685
if (argument is double) {
8786
return '$_prefixForDoubleIds$argument';

dwds/lib/src/utilities/dart_uri.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ class DartUri {
7878
// Both currentDirectoryUri and the libraryUri path should have '/'
7979
// separators, so we can join them as url paths to get the absolute file
8080
// url.
81-
var libraryPath =
82-
p.url.join('$currentDirectoryUri', uri.path.substring(1));
81+
var libraryPath = p.url.join(currentDirectoryUri, uri.path.substring(1));
8382
_libraryNamesByPath[libraryPath] = libraryUri;
8483
} else if (uri.scheme == 'package') {
8584
var libraryPath = _packageConfig.resolve(uri);

dwds/test/events_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ void main() {
4141
});
4242

4343
test('emits HTTP_REQUEST_EXCEPTION event', () async {
44-
final throwAsyncException = () async {
44+
Future<void> throwAsyncException() async {
4545
await Future.delayed(const Duration(milliseconds: 100));
4646
throw Exception('async error');
47-
};
47+
}
4848

4949
// The events stream is a broadcast stream so start listening
5050
// before the action.

dwds/test/expression_compiler_service_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ void main() async {
5959
var port = server.port;
6060

6161
// start expression compilation service
62-
final assetHandler = (request) =>
62+
Response assetHandler(request) =>
6363
Response(200, body: File.fromUri(kernel).readAsBytesSync());
6464
service =
6565
ExpressionCompilerService('localhost', port, assetHandler, false);

dwds/test/fixtures/context.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ class TestContext {
343343
webkitDebugger = WebkitDebugger(WipDebugger(tabConnection));
344344
}
345345

346-
Future<Null> tearDown() async {
346+
Future<void> tearDown() async {
347347
await webDriver?.quit(closeSession: true);
348348
chromeDriver?.kill();
349349
DartUri.currentDirectory = p.current;

dwds/test/fixtures/utilities.dart

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,8 @@ import 'package:path/path.dart' as p;
1414
/// Connects to the `build_runner` daemon.
1515
Future<BuildDaemonClient> connectClient(String workingDirectory,
1616
List<String> options, Function(ServerLog) logHandler) =>
17-
BuildDaemonClient.connect(
18-
workingDirectory,
19-
[dartPath]
20-
..addAll(['run', 'build_runner', 'daemon'])
21-
..addAll(options),
17+
BuildDaemonClient.connect(workingDirectory,
18+
[dartPath, 'run', 'build_runner', 'daemon', ...options],
2219
logHandler: logHandler);
2320

2421
/// The path to the root directory of the SDK.

dwds/web/run_main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ final ScriptElement Function() _createScript = (() {
1212
})();
1313

1414
// According to the CSP3 spec a nonce must be a valid base64 string.
15-
final _noncePattern = RegExp('^[\\w+\/_-]+[=]{0,2}\$');
15+
final _noncePattern = RegExp('^[\\w+/_-]+[=]{0,2}\$');
1616

1717
/// Returns CSP nonce, if set for any script tag.
1818
String _findNonce() {

webdev/lib/src/daemon_client.dart

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,8 @@ import 'util.dart';
1616
/// Connects to the `build_runner` daemon.
1717
Future<BuildDaemonClient> connectClient(String workingDirectory,
1818
List<String> options, Function(ServerLog) logHandler) =>
19-
BuildDaemonClient.connect(
20-
workingDirectory,
21-
[dartPath]
22-
..addAll(['run', 'build_runner', 'daemon'])
23-
..addAll(options),
19+
BuildDaemonClient.connect(workingDirectory,
20+
[dartPath, 'run', 'build_runner', 'daemon', ...options],
2421
logHandler: logHandler);
2522

2623
/// Returns the port of the daemon asset server.

webdev/lib/src/logging.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ void configureLogWriter(bool verbose, {LogWriter customLogWriter}) {
2828
});
2929
}
3030

31+
// ignore: prefer_function_declarations_over_variables
3132
LogWriter _logWriter =
3233
(level, message, {String error, String loggerName, String stackTrace}) {
3334
// Erases the previous line

0 commit comments

Comments
 (0)