Skip to content

Enable pkg:lints recommended lints #1444

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ linter:
- empty_catches
- empty_constructor_bodies
- empty_statements
- exhaustive_cases
- file_names
- hash_and_equals
- implementation_imports
Expand All @@ -66,18 +67,23 @@ linter:
- prefer_equal_for_default_values
- prefer_final_fields
- prefer_for_elements_to_map_fromIterable
- prefer_function_declarations_over_variables
- prefer_generic_function_type_aliases
- prefer_if_null_operators
- prefer_initializing_formals
- prefer_inlined_adds
- prefer_interpolation_to_compose_strings
- prefer_is_empty
- prefer_is_not_empty
- prefer_is_not_operator
- prefer_iterable_whereType
- prefer_null_aware_operators
- prefer_relative_imports
- prefer_single_quotes
- prefer_spread_collections
- prefer_typing_uninitialized_variables
- prefer_void_to_null
- provide_deprecation_message
- recursive_getters
- slash_for_doc_comments
- test_types_in_equals
Expand All @@ -91,8 +97,11 @@ linter:
- unnecessary_new
- unnecessary_null_aware_assignments
- unnecessary_null_in_if_null_operators
- unnecessary_overrides
- unnecessary_parenthesis
- unnecessary_statements
- unnecessary_string_escapes
- unnecessary_string_interpolations
- unnecessary_this
- unrelated_type_equality_checks
- use_function_type_syntax_for_parameters
Expand Down
2 changes: 1 addition & 1 deletion dwds/lib/src/debugging/debugger.dart
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class Debugger extends Domain {
return debugger;
}

Future<Null> _initialize() async {
Future<void> _initialize() async {
// We must add a listener before enabling the debugger otherwise we will
// miss events.
// Allow a null debugger/connection for unit tests.
Expand Down
2 changes: 1 addition & 1 deletion dwds/lib/src/debugging/inspector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class AppInspector extends Domain {
isolateFlags: [])
..extensionRPCs = [];
AppInspector appInspector;
var provider = () => appInspector;
AppInspector provider() => appInspector;
var libraryHelper = LibraryHelper(provider);
var classHelper = ClassHelper(provider);
var instanceHelper = InstanceHelper(provider);
Expand Down
2 changes: 1 addition & 1 deletion dwds/lib/src/handlers/injector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class DwdsInjector {
var requestedUri = request.requestedUri;
var appId = base64
.encode(md5.convert(utf8.encode('$requestedUri')).bytes);
var scheme = '${request.requestedUri.scheme}';
var scheme = request.requestedUri.scheme;
if (!_useSseForInjectedClient) {
// Switch http->ws and https->wss.
scheme = scheme.replaceFirst('http', 'ws');
Expand Down
4 changes: 2 additions & 2 deletions dwds/lib/src/services/debug_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class DebugService {
scheme: 'http',
host: hostname,
port: port,
path: '$authToken',
path: authToken,
),
serviceUri: Uri(
scheme: 'http',
Expand All @@ -181,7 +181,7 @@ class DebugService {
scheme: 'ws',
host: hostname,
port: port,
path: '$authToken',
path: authToken,
))
.toString();
}
Expand Down
3 changes: 1 addition & 2 deletions dwds/lib/src/utilities/conversions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// @dart = 2.9

/// Functions for converting between the different object references we use.

import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart';

/// Convert [argument] to a form usable in WIP evaluation calls.
Expand Down Expand Up @@ -81,7 +80,7 @@ RemoteObject remoteObjectFor(String dartId) {
/// RemoteObjects.
String dartIdFor(Object argument) {
if (argument == null) {
return '$_nullId';
return _nullId;
}
if (argument is double) {
return '$_prefixForDoubleIds$argument';
Expand Down
3 changes: 1 addition & 2 deletions dwds/lib/src/utilities/dart_uri.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ class DartUri {
// Both currentDirectoryUri and the libraryUri path should have '/'
// separators, so we can join them as url paths to get the absolute file
// url.
var libraryPath =
p.url.join('$currentDirectoryUri', uri.path.substring(1));
var libraryPath = p.url.join(currentDirectoryUri, uri.path.substring(1));
_libraryNamesByPath[libraryPath] = libraryUri;
} else if (uri.scheme == 'package') {
var libraryPath = _packageConfig.resolve(uri);
Expand Down
4 changes: 2 additions & 2 deletions dwds/test/events_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ void main() {
});

test('emits HTTP_REQUEST_EXCEPTION event', () async {
final throwAsyncException = () async {
Future<void> throwAsyncException() async {
await Future.delayed(const Duration(milliseconds: 100));
throw Exception('async error');
};
}

// The events stream is a broadcast stream so start listening
// before the action.
Expand Down
2 changes: 1 addition & 1 deletion dwds/test/expression_compiler_service_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void main() async {
var port = server.port;

// start expression compilation service
final assetHandler = (request) =>
Response assetHandler(request) =>
Response(200, body: File.fromUri(kernel).readAsBytesSync());
service =
ExpressionCompilerService('localhost', port, assetHandler, false);
Expand Down
2 changes: 1 addition & 1 deletion dwds/test/fixtures/context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ class TestContext {
webkitDebugger = WebkitDebugger(WipDebugger(tabConnection));
}

Future<Null> tearDown() async {
Future<void> tearDown() async {
await webDriver?.quit(closeSession: true);
chromeDriver?.kill();
DartUri.currentDirectory = p.current;
Expand Down
7 changes: 2 additions & 5 deletions dwds/test/fixtures/utilities.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@ import 'package:path/path.dart' as p;
/// Connects to the `build_runner` daemon.
Future<BuildDaemonClient> connectClient(String workingDirectory,
List<String> options, Function(ServerLog) logHandler) =>
BuildDaemonClient.connect(
workingDirectory,
[dartPath]
..addAll(['run', 'build_runner', 'daemon'])
..addAll(options),
BuildDaemonClient.connect(workingDirectory,
[dartPath, 'run', 'build_runner', 'daemon', ...options],
logHandler: logHandler);

/// The path to the root directory of the SDK.
Expand Down
2 changes: 1 addition & 1 deletion dwds/web/run_main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ final ScriptElement Function() _createScript = (() {
})();

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

/// Returns CSP nonce, if set for any script tag.
String _findNonce() {
Expand Down
7 changes: 2 additions & 5 deletions webdev/lib/src/daemon_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,8 @@ import 'util.dart';
/// Connects to the `build_runner` daemon.
Future<BuildDaemonClient> connectClient(String workingDirectory,
List<String> options, Function(ServerLog) logHandler) =>
BuildDaemonClient.connect(
workingDirectory,
[dartPath]
..addAll(['run', 'build_runner', 'daemon'])
..addAll(options),
BuildDaemonClient.connect(workingDirectory,
[dartPath, 'run', 'build_runner', 'daemon', ...options],
logHandler: logHandler);

/// Returns the port of the daemon asset server.
Expand Down
1 change: 1 addition & 0 deletions webdev/lib/src/logging.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ void configureLogWriter(bool verbose, {LogWriter customLogWriter}) {
});
}

// ignore: prefer_function_declarations_over_variables
LogWriter _logWriter =
(level, message, {String error, String loggerName, String stackTrace}) {
// Erases the previous line
Expand Down