Skip to content

Commit 85a384b

Browse files
authored
Unify on one analysis_options file (#280)
Apply fixes to shelf_router and shelf_router_generator
1 parent e2f26c8 commit 85a384b

File tree

10 files changed

+17
-91
lines changed

10 files changed

+17
-91
lines changed

analysis_options.yaml

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,43 +10,30 @@ linter:
1010
rules:
1111
- always_declare_return_types
1212
- avoid_unused_constructor_parameters
13-
- await_only_futures
14-
- camel_case_types
1513
- cancel_subscriptions
16-
- constant_identifier_names
17-
- control_flow_in_finally
1814
- depend_on_referenced_packages
1915
- directives_ordering
20-
- empty_statements
21-
- hash_and_equals
22-
- implementation_imports
23-
- iterable_contains_unrelated_type
2416
- library_private_types_in_public_api
2517
- lines_longer_than_80_chars
26-
- list_remove_unrelated_type
2718
- literal_only_boolean_expressions
2819
- missing_whitespace_between_adjacent_strings
2920
- no_adjacent_strings_in_list
3021
- no_leading_underscores_for_library_prefixes
3122
- no_leading_underscores_for_local_identifiers
3223
- no_runtimeType_toString
33-
- non_constant_identifier_names
3424
- null_check_on_nullable_type_parameter
3525
- omit_local_variable_types
36-
- overridden_fields
3726
- package_api_docs
38-
- package_names
39-
- package_prefixed_library_names
4027
- prefer_relative_imports
4128
- prefer_single_quotes
4229
- test_types_in_equals
4330
- throw_in_finally
4431
- type_annotate_public_apis
4532
- unawaited_futures
4633
- unnecessary_await_in_return
47-
- unnecessary_brace_in_string_interps
4834
- unnecessary_constructor_name
4935
- unnecessary_lambdas
5036
- unnecessary_late
5137
- unnecessary_null_aware_assignments
5238
- unnecessary_nullable_for_final_variable_declarations
39+
- use_super_parameters

pkgs/shelf_router/analysis_options.yaml

Lines changed: 0 additions & 1 deletion
This file was deleted.

pkgs/shelf_router/example/main.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
// limitations under the License.
1414

1515
import 'dart:async' show Future;
16-
import 'package:shelf_router/shelf_router.dart';
16+
1717
import 'package:shelf/shelf.dart';
1818
import 'package:shelf/shelf_io.dart' as shelf_io;
19+
import 'package:shelf_router/shelf_router.dart';
1920

2021
class Service {
2122
// The [Router] can be used to create a handler, which can be used with
@@ -39,7 +40,7 @@ class Service {
3940

4041
// Handlers can be asynchronous (returning `FutureOr` is also allowed).
4142
router.get('/wave', (Request request) async {
42-
await Future.delayed(Duration(milliseconds: 100));
43+
await Future<void>.delayed(Duration(milliseconds: 100));
4344
return Response.ok('_o/');
4445
});
4546

pkgs/shelf_router/lib/shelf_router.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@
7676
/// await io.serve(service.router.handler, 'localhost', 8080);
7777
/// }
7878
/// ```
79-
///
8079
library shelf_router;
8180

82-
import 'package:shelf_router/src/router.dart';
83-
import 'package:shelf_router/src/route.dart';
84-
export 'package:shelf_router/src/router.dart';
81+
import 'src/route.dart';
82+
import 'src/router.dart';
83+
8584
export 'package:shelf_router/src/route.dart';
85+
export 'package:shelf_router/src/router.dart';

pkgs/shelf_router/lib/src/route.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414

1515
import 'package:meta/meta.dart' show sealed;
16-
import 'package:shelf_router/src/router.dart';
16+
import 'router.dart';
1717

1818
/// Annotation for handler methods that requests should be routed when using
1919
/// package `shelf_router_generator`.

pkgs/shelf_router/lib/src/router.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ import 'dart:convert';
1818
import 'package:http_methods/http_methods.dart';
1919
import 'package:meta/meta.dart' show sealed;
2020
import 'package:shelf/shelf.dart';
21-
import 'package:shelf_router/src/router_entry.dart' show RouterEntry;
21+
22+
import 'router_entry.dart' show RouterEntry;
2223

2324
/// Get a URL parameter captured by the [Router].
2425
@Deprecated('Use Request.params instead')
@@ -294,7 +295,7 @@ class _RouteNotFoundResponse extends Response {
294295
Response change({
295296
Map<String, /* String | List<String> */ Object?>? headers,
296297
Map<String, Object?>? context,
297-
body,
298+
Object? body,
298299
}) {
299300
return super.change(
300301
headers: headers,

pkgs/shelf_router/lib/src/router_entry.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// limitations under the License.
1414

1515
import 'dart:async';
16+
1617
import 'package:shelf/shelf.dart';
1718

1819
/// Check if the [regexp] is non-capturing.
@@ -102,12 +103,12 @@ class RouterEntry {
102103

103104
return await _middleware((request) async {
104105
if (_handler is Handler || _params.isEmpty) {
105-
return await _handler(request);
106+
return await _handler(request) as Response;
106107
}
107108
return await Function.apply(_handler, [
108109
request,
109110
..._params.map((n) => params[n]),
110-
]);
111+
]) as Response;
111112
})(request);
112113
}
113114
}

pkgs/shelf_router_generator/analysis_options.yaml

Lines changed: 0 additions & 63 deletions
This file was deleted.

pkgs/shelf_router_generator/example/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class Service {
3838
// Handlers can be asynchronous (returning `FutureOr` is also allowed).
3939
@Route.get('/wave')
4040
Future<Response> _wave(Request request) async {
41-
await Future.delayed(const Duration(milliseconds: 100));
41+
await Future<void>.delayed(const Duration(milliseconds: 100));
4242
return Response.ok('_o/');
4343
}
4444

pkgs/shelf_router_generator/test/server/service.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class Service {
2929

3030
@Route.get('/wave')
3131
FutureOr<Response> _wave(Request request) async {
32-
await Future.delayed(const Duration(milliseconds: 50));
32+
await Future<void>.delayed(const Duration(milliseconds: 50));
3333
return Response.ok('_o/');
3434
}
3535

0 commit comments

Comments
 (0)