From 5eef432e2ad9c0512d3ca602ca25d369bd19f1a9 Mon Sep 17 00:00:00 2001 From: Tobe O Date: Thu, 6 Jun 2019 10:37:27 -0400 Subject: [PATCH] Curly brace fixes... --- lib/src/core/driver.dart | 4 ++-- lib/src/core/injection.dart | 6 +++--- lib/src/core/map_service.dart | 8 ++++---- lib/src/core/request_context.dart | 4 ++-- lib/src/core/response_context.dart | 14 ++++++++------ lib/src/core/server.dart | 4 ++-- lib/src/core/service.dart | 12 ++++++------ lib/src/http/http_response_context.dart | 16 ++++++++-------- lib/src/http2/http2_response_context.dart | 16 ++++++++-------- test/pretty_log.dart | 10 +++++----- 10 files changed, 48 insertions(+), 46 deletions(-) diff --git a/lib/src/core/driver.dart b/lib/src/core/driver.dart index cf87f5e2..b15df8e5 100644 --- a/lib/src/core/driver.dart +++ b/lib/src/core/driver.dart @@ -326,9 +326,9 @@ abstract class Driver< Converter, List> encoder; String key = encodingName; - if (res.encoders.containsKey(encodingName)) + if (res.encoders.containsKey(encodingName)) { encoder = res.encoders[encodingName]; - else if (encodingName == '*') { + } else if (encodingName == '*') { encoder = res.encoders[key = res.encoders.keys.first]; } diff --git a/lib/src/core/injection.dart b/lib/src/core/injection.dart index 3c2a300c..1f08de21 100644 --- a/lib/src/core/injection.dart +++ b/lib/src/core/injection.dart @@ -44,11 +44,11 @@ resolveInjection(requirement, InjectionRequest injection, RequestContext req, } if (req.params.containsKey(requirement)) { return req.params[requirement]; - } else if ((propFromApp = req.app.findProperty(requirement)) != null) + } else if ((propFromApp = req.app.findProperty(requirement)) != null) { return propFromApp; - else if (injection.optional.contains(requirement)) + } else if (injection.optional.contains(requirement)) { return null; - else if (throwOnUnresolved) { + } else if (throwOnUnresolved) { throw ArgumentError( "Cannot resolve parameter '$requirement' within handler."); } diff --git a/lib/src/core/map_service.dart b/lib/src/core/map_service.dart index e628a4a6..a7b50915 100644 --- a/lib/src/core/map_service.dart +++ b/lib/src/core/map_service.dart @@ -37,9 +37,9 @@ class MapService extends Service> { bool Function(Map) _matchesId(id) { return (Map item) { - if (item['id'] == null) + if (item['id'] == null) { return false; - else if (autoIdAndDateFields != false) { + } else if (autoIdAndDateFields != false) { return item['id'] == id?.toString(); } else { return item['id'] == id; @@ -56,9 +56,9 @@ class MapService extends Service> { return Future.value(items.where((item) { for (var key in query.keys) { - if (!item.containsKey(key)) + if (!item.containsKey(key)) { return false; - else if (item[key] != query[key]) return false; + } else if (item[key] != query[key]) return false; } return true; diff --git a/lib/src/core/request_context.dart b/lib/src/core/request_context.dart index f50f6e29..d25a5804 100644 --- a/lib/src/core/request_context.dart +++ b/lib/src/core/request_context.dart @@ -209,9 +209,9 @@ abstract class RequestContext { _acceptHeaderCache ??= headers.value('accept'); - if (_acceptHeaderCache == null) + if (_acceptHeaderCache == null) { return false; - else if (strict != true && _acceptHeaderCache.contains('*/*')) { + } else if (strict != true && _acceptHeaderCache.contains('*/*')) { return true; } else { return _acceptHeaderCache.contains(contentTypeString); diff --git a/lib/src/core/response_context.dart b/lib/src/core/response_context.dart index 839df5b1..f0428055 100644 --- a/lib/src/core/response_context.dart +++ b/lib/src/core/response_context.dart @@ -336,18 +336,20 @@ abstract class ResponseContext @override void addError(Object error, [StackTrace stackTrace]) { - if (_done?.isCompleted == false) + if (_done?.isCompleted == false) { _done.completeError(error, stackTrace); - else if (_done == null) Zone.current.handleUncaughtError(error, stackTrace); + } else if (_done == null) { + Zone.current.handleUncaughtError(error, stackTrace); + } } /// Writes data to the response. void write(value, {Encoding encoding}) { encoding ??= utf8; - if (!isOpen && isBuffered) + if (!isOpen && isBuffered) { throw closed(); - else if (!isBuffered) { + } else if (!isBuffered) { add(encoding.encode(value.toString())); } else { buffer.add(encoding.encode(value.toString())); @@ -356,9 +358,9 @@ abstract class ResponseContext @override void writeCharCode(int charCode) { - if (!isOpen && isBuffered) + if (!isOpen && isBuffered) { throw closed(); - else if (!isBuffered) { + } else if (!isBuffered) { add([charCode]); } else { buffer.addByte(charCode); diff --git a/lib/src/core/server.dart b/lib/src/core/server.dart index a072c1c1..5ed7147d 100644 --- a/lib/src/core/server.dart +++ b/lib/src/core/server.dart @@ -269,9 +269,9 @@ class Angel extends Routable { Future executeHandler( handler, RequestContext req, ResponseContext res) { return getHandlerResult(handler, req, res).then((result) { - if (result == null) + if (result == null) { return false; - else if (result is bool) { + } else if (result is bool) { return result; } else if (result != null) { return res.serialize(result); diff --git a/lib/src/core/service.dart b/lib/src/core/service.dart index bbe147be..7592c48d 100644 --- a/lib/src/core/service.dart +++ b/lib/src/core/service.dart @@ -196,17 +196,17 @@ class Service extends Routable { /// /// For example, `parseId` attempts to parse the value as a [bool]. static T parseId(id) { - if (id == 'null' || id == null) + if (id == 'null' || id == null) { return null; - else if (T == String) + } else if (T == String) { return id.toString() as T; - else if (T == int) + } else if (T == int) { return int.parse(id.toString()) as T; - else if (T == bool) + } else if (T == bool) { return (id == true || id?.toString() == 'true') as T; - else if (T == double) + } else if (T == double) { return double.parse(id.toString()) as T; - else if (T == num) { + } else if (T == num) { return num.parse(id.toString()) as T; } else { return id as T; diff --git a/lib/src/http/http_response_context.dart b/lib/src/http/http_response_context.dart index 3ec53236..8903d245 100644 --- a/lib/src/http/http_response_context.dart +++ b/lib/src/http/http_response_context.dart @@ -104,9 +104,9 @@ class HttpResponseContext 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]; } @@ -138,9 +138,9 @@ class HttpResponseContext 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]; } @@ -157,9 +157,9 @@ class HttpResponseContext extends ResponseContext { @override void add(List data) { - if (_isClosed && isBuffered) + if (_isClosed && isBuffered) { throw ResponseContext.closed(); - else if (!isBuffered) { + } else if (!isBuffered) { if (!_isClosed) { _openStream(); @@ -169,9 +169,9 @@ class HttpResponseContext 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]; } diff --git a/lib/src/http2/http2_response_context.dart b/lib/src/http2/http2_response_context.dart index 7e033fbc..55fb6d45 100644 --- a/lib/src/http2/http2_response_context.dart +++ b/lib/src/http2/http2_response_context.dart @@ -82,9 +82,9 @@ class Http2ResponseContext 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]; } @@ -142,9 +142,9 @@ class Http2ResponseContext 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]; } @@ -161,9 +161,9 @@ class Http2ResponseContext extends ResponseContext { @override void add(List data) { - if (!isOpen && isBuffered) + if (!isOpen && isBuffered) { throw ResponseContext.closed(); - else if (!isBuffered) { + } else if (!isBuffered) { _openStream(); if (!_isClosed) { @@ -173,9 +173,9 @@ class Http2ResponseContext 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]; } diff --git a/test/pretty_log.dart b/test/pretty_log.dart index 9c03c110..83427f07 100644 --- a/test/pretty_log.dart +++ b/test/pretty_log.dart @@ -20,15 +20,15 @@ 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.CONFIG || + } else if (level == Level.CONFIG || level == Level.FINE || level == Level.FINER || level == Level.FINEST) return lightGray;