enable and fix a number of lints
diff --git a/analysis_options.yaml b/analysis_options.yaml
index 749f62a..f8eebb4 100644
--- a/analysis_options.yaml
+++ b/analysis_options.yaml
@@ -4,8 +4,80 @@
implicit-casts: false
linter:
rules:
+ - always_declare_return_types
+ - annotate_overrides
+ - avoid_empty_else
+ - avoid_function_literals_in_foreach_calls
+ - avoid_init_to_null
+ - avoid_null_checks_in_equality_operators
+ - avoid_relative_lib_imports
+ - avoid_renaming_method_parameters
+ - avoid_return_types_on_setters
+ - avoid_returning_null
+ - avoid_returning_null_for_future
+ - avoid_shadowing_type_parameters
+ - avoid_types_as_parameter_names
+ - avoid_unused_constructor_parameters
- await_only_futures
+ - camel_case_types
+ - cancel_subscriptions
+ - comment_references
+ - constant_identifier_names
+ - control_flow_in_finally
+ - directives_ordering
+ - empty_catches
+ - empty_constructor_bodies
+ - empty_statements
+ - hash_and_equals
- implementation_imports
+ - invariant_booleans
+ - iterable_contains_unrelated_type
+ - library_names
+ - library_prefixes
+ - list_remove_unrelated_type
+ - literal_only_boolean_expressions
+ - no_adjacent_strings_in_list
+ - no_duplicate_case_values
+ - non_constant_identifier_names
+ - null_closures
+ - omit_local_variable_types
+ - only_throw_errors
+ - overridden_fields
+ - package_api_docs
+ - package_names
+ - package_prefixed_library_names
+ - prefer_adjacent_string_concatenation
+ - prefer_collection_literals
+ - prefer_conditional_assignment
+ - prefer_const_constructors
+ - prefer_contains
+ - prefer_equal_for_default_values
+ - prefer_final_fields
+ #- prefer_final_locals
+ - prefer_initializing_formals
+ - prefer_interpolation_to_compose_strings
+ - prefer_is_empty
+ - prefer_is_not_empty
+ #- prefer_single_quotes
- prefer_typing_uninitialized_variables
+ - recursive_getters
+ - slash_for_doc_comments
+ - super_goes_last
+ - test_types_in_equals
+ - throw_in_finally
+ - type_init_formals
+ - unawaited_futures
+ - unnecessary_await_in_return
+ - unnecessary_brace_in_string_interps
- unnecessary_const
+ - unnecessary_getters_setters
+ - unnecessary_lambdas
- unnecessary_new
+ - unnecessary_null_aware_assignments
+ - unnecessary_parenthesis
+ - unnecessary_statements
+ - unnecessary_this
+ - unrelated_type_equality_checks
+ - use_function_type_syntax_for_parameters
+ - use_rethrow_when_possible
+ - valid_regexps
diff --git a/lib/pool.dart b/lib/pool.dart
index 6994c76..a97ec75 100644
--- a/lib/pool.dart
+++ b/lib/pool.dart
@@ -117,7 +117,7 @@
/// Future.
///
/// The return value of [callback] is piped to the returned Future.
- Future<T> withResource<T>(FutureOr<T> callback()) async {
+ Future<T> withResource<T>(FutureOr<T> Function() callback) async {
if (isClosed) {
throw StateError("withResource() may not be called on a closed Pool.");
}
@@ -174,7 +174,7 @@
/// If there are any pending requests, this will fire the oldest one after
/// running [onRelease].
- void _onResourceReleaseAllowed(onRelease()) {
+ void _onResourceReleaseAllowed(Function() onRelease) {
_resetTimer();
if (_requestedResources.isNotEmpty) {
@@ -196,7 +196,7 @@
///
/// Futures returned by [_runOnRelease] always complete in the order they were
/// created, even if earlier [onRelease] callbacks take longer to run.
- Future<PoolResource> _runOnRelease(onRelease()) {
+ Future<PoolResource> _runOnRelease(Function() onRelease) {
Future.sync(onRelease).then((value) {
_onReleaseCompleters.removeFirst().complete(PoolResource._(this));
}).catchError((error, StackTrace stackTrace) {
@@ -242,7 +242,7 @@
class PoolResource {
final Pool _pool;
- /// Whether [this] has been released yet.
+ /// Whether `this` has been released yet.
bool _released = false;
PoolResource._(this._pool);
@@ -269,7 +269,7 @@
/// This is useful when a resource's main function is complete, but it may
/// produce additional information later on. For example, an isolate's task
/// may be complete, but it could still emit asynchronous errors.
- void allowRelease(onRelease()) {
+ void allowRelease(Function() onRelease) {
if (_released) {
throw StateError("A PoolResource may only be released once.");
}
diff --git a/test/pool_test.dart b/test/pool_test.dart
index 66624cf..6c9d0a5 100644
--- a/test/pool_test.dart
+++ b/test/pool_test.dart
@@ -161,7 +161,7 @@
for (var i = 0; i < 50; i++) {
expect(pool.request(), completes);
}
- expect(pool.request(), throwsA(TypeMatcher<TimeoutException>()));
+ expect(pool.request(), throwsA(const TypeMatcher<TimeoutException>()));
async.elapse(Duration(seconds: 6));
});
@@ -456,7 +456,7 @@
///
/// This should only be called within a [FakeAsync.run] zone.
Matcher get doesNotComplete => predicate((future) {
- expect(future, TypeMatcher<Future>());
+ expect(future, const TypeMatcher<Future>());
var stack = Trace.current(1);
future.then((_) => registerException(