analysis_options: disallow implicit casts
diff --git a/analysis_options.yaml b/analysis_options.yaml
index bd5c120..f04af43 100644
--- a/analysis_options.yaml
+++ b/analysis_options.yaml
@@ -1,4 +1,7 @@
include: package:pedantic/analysis_options.yaml
+analyzer:
+ strong-mode:
+ implicit-casts: false
linter:
rules:
- avoid_empty_else
diff --git a/lib/shelf_io.dart b/lib/shelf_io.dart
index 30ed0d1..7f28a17 100644
--- a/lib/shelf_io.dart
+++ b/lib/shelf_io.dart
@@ -71,7 +71,7 @@
///
/// Returns a [Future] which completes when the request has been handled.
Future handleRequest(HttpRequest request, Handler handler) async {
- var shelfRequest;
+ Request shelfRequest;
try {
shelfRequest = _fromHttpRequest(request);
} catch (error, stackTrace) {
@@ -83,7 +83,7 @@
// TODO(nweiz): abstract out hijack handling to make it easier to implement an
// adapter.
- var response;
+ Response response;
try {
response = await handler(shelfRequest);
} on HijackException catch (error, stackTrace) {
@@ -143,7 +143,8 @@
Future _writeResponse(Response response, HttpResponse httpResponse) {
if (response.context.containsKey("shelf.io.buffer_output")) {
- httpResponse.bufferOutput = response.context["shelf.io.buffer_output"];
+ httpResponse.bufferOutput =
+ response.context["shelf.io.buffer_output"] as bool;
}
httpResponse.statusCode = response.statusCode;
diff --git a/lib/src/middleware.dart b/lib/src/middleware.dart
index 445efdd..05b9b47 100644
--- a/lib/src/middleware.dart
+++ b/lib/src/middleware.dart
@@ -54,7 +54,7 @@
if (responseHandler == null) responseHandler = (response) => response;
- var onError;
+ void Function(Object, StackTrace) onError;
if (errorHandler != null) {
onError = (error, stackTrace) {
if (error is HijackException) throw error;
diff --git a/lib/src/middleware/logger.dart b/lib/src/middleware/logger.dart
index 412ce11..0d11ca1 100644
--- a/lib/src/middleware/logger.dart
+++ b/lib/src/middleware/logger.dart
@@ -34,7 +34,7 @@
logger(msg, false);
return response;
- }, onError: (error, stackTrace) {
+ }, onError: (error, StackTrace stackTrace) {
if (error is HijackException) throw error;
var msg = _getErrorMessage(startTime, request.requestedUri,
diff --git a/test/add_chunked_encoding_test.dart b/test/add_chunked_encoding_test.dart
index 2b06ad0..2ae1dbf 100644
--- a/test/add_chunked_encoding_test.dart
+++ b/test/add_chunked_encoding_test.dart
@@ -60,5 +60,5 @@
});
}
-Future<Response> _chunkResponse(Response response) =>
+FutureOr<Response> _chunkResponse(Response response) =>
addChunkedEncoding((_) => response)(null);