From 6568dc230533b57289a20e2fdb56af8c7a3d90f0 Mon Sep 17 00:00:00 2001 From: Tobe O Date: Fri, 9 Aug 2019 10:53:38 -0400 Subject: [PATCH] pedantic --- benchmark/util.dart | 6 +++--- example/pretty_log.dart | 10 +++++----- lib/src/wings_request.dart | 4 ++-- lib/src/wings_response.dart | 25 ++++++++++++++----------- 4 files changed, 24 insertions(+), 21 deletions(-) diff --git a/benchmark/util.dart b/benchmark/util.dart index 80b03ade..0da16c2d 100644 --- a/benchmark/util.dart +++ b/benchmark/util.dart @@ -5,7 +5,6 @@ import 'package:angel_framework/angel_framework.dart'; import 'package:angel_framework/http.dart'; import 'package:angel_wings/angel_wings.dart'; import 'package:io/ansi.dart'; -import 'package:pedantic/pedantic.dart'; import 'package:tuple/tuple.dart'; Future _runWrk( @@ -89,10 +88,11 @@ void _angelIsolate(Tuple2 args) { var app = Angel(); Driver driver; - if (args.item2 == 'angel_http') + if (args.item2 == 'angel_http') { driver = AngelHttp.custom(app, startShared); - else if (args.item2 == 'angel_wings') + } else if (args.item2 == 'angel_wings') { driver = AngelWings.custom(app, startSharedWings); + } await app.configure(args.item1.setupAngel); await driver.startServer(InternetAddress.loopbackIPv4, testPort); diff --git a/example/pretty_log.dart b/example/pretty_log.dart index 3f8b452d..2172fdd0 100644 --- a/example/pretty_log.dart +++ b/example/pretty_log.dart @@ -22,14 +22,14 @@ void prettyLog(LogRecord record) { /// Chooses a color based on the logger [level]. AnsiCode chooseLogColor(Level level) { - if (level == Level.SHOUT) + if (level == Level.SHOUT) { return backgroundRed; - else if (level == Level.SEVERE) + } else if (level == Level.SEVERE) { return red; - else if (level == Level.WARNING) + } else if (level == Level.WARNING) { return yellow; - else if (level == Level.INFO) + } else if (level == Level.INFO) { return cyan; - else if (level == Level.FINER || level == Level.FINEST) return lightGray; + } else if (level == Level.FINER || level == Level.FINEST) return lightGray; return resetAll; } diff --git a/lib/src/wings_request.dart b/lib/src/wings_request.dart index 22d12ac3..bb066028 100644 --- a/lib/src/wings_request.dart +++ b/lib/src/wings_request.dart @@ -9,7 +9,7 @@ import 'wings_socket.dart'; enum _ParseState { method, url, headerField, headerValue, body } -final RegExp _straySlashes = new RegExp(r'(^/+)|(/+$)'); +final RegExp _straySlashes = RegExp(r'(^/+)|(/+$)'); class WingsRequestContext extends RequestContext { final WingsClientSocket rawRequest; @@ -91,7 +91,7 @@ class WingsRequestContext extends RequestContext { case PURGE: return 'PURGE'; default: - throw new ArgumentError('Unknown method $method.'); + throw ArgumentError('Unknown method $method.'); } } diff --git a/lib/src/wings_response.dart b/lib/src/wings_response.dart index 206ea4b9..cdb22099 100644 --- a/lib/src/wings_response.dart +++ b/lib/src/wings_response.dart @@ -57,8 +57,9 @@ class WingsResponseContext extends ResponseContext { } } - if (contentType != null) + if (contentType != null) { outHeaders['content-type'] = contentType.toString(); + } if (encoders.isNotEmpty && correspondingRequest != null) { if (_allowedEncodings != null) { @@ -66,9 +67,9 @@ class WingsResponseContext extends ResponseContext { Converter, List> encoder; String key = encodingName; - if (encoders.containsKey(encodingName)) + if (encoders.containsKey(encodingName)) { encoder = encoders[encodingName]; - else if (encodingName == '*') { + } else if (encodingName == '*') { encoder = encoders[key = encoders.keys.first]; } @@ -116,9 +117,9 @@ class WingsResponseContext extends ResponseContext { Converter, List> encoder; String key = encodingName; - if (encoders.containsKey(encodingName)) + if (encoders.containsKey(encodingName)) { encoder = encoders[encodingName]; - else if (encodingName == '*') { + } else if (encodingName == '*') { encoder = encoders[key = encoders.keys.first]; } @@ -131,17 +132,18 @@ class WingsResponseContext extends ResponseContext { } return output.forEach((buf) { - if (!_isClosed) + if (!_isClosed) { writeToNativeSocket( rawResponse, buf is Uint8List ? buf : Uint8List.fromList(buf)); + } }); } @override void add(List data) { - if (_isClosed && isBuffered) + if (_isClosed && isBuffered) { throw ResponseContext.closed(); - else if (!isBuffered) { + } else if (!isBuffered) { if (!_isClosed) { _openStream(); @@ -151,9 +153,9 @@ class WingsResponseContext extends ResponseContext { Converter, List> encoder; String key = encodingName; - if (encoders.containsKey(encodingName)) + if (encoders.containsKey(encodingName)) { encoder = encoders[encodingName]; - else if (encodingName == '*') { + } else if (encodingName == '*') { encoder = encoders[key = encoders.keys.first]; } @@ -168,8 +170,9 @@ class WingsResponseContext extends ResponseContext { writeToNativeSocket( rawResponse, data is Uint8List ? data : Uint8List.fromList(data)); } - } else + } else { buffer.add(data); + } } @override