Curly brace fixes...

This commit is contained in:
Tobe O 2019-06-06 10:37:27 -04:00
parent d0e765dcd4
commit 5eef432e2a
10 changed files with 48 additions and 46 deletions

View file

@ -326,9 +326,9 @@ abstract class Driver<
Converter<List<int>, List<int>> 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];
}

View file

@ -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.");
}

View file

@ -37,9 +37,9 @@ class MapService extends Service<String, Map<String, dynamic>> {
bool Function(Map<String, dynamic>) _matchesId(id) {
return (Map<String, dynamic> 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<String, Map<String, dynamic>> {
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;

View file

@ -209,9 +209,9 @@ abstract class RequestContext<RawRequest> {
_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);

View file

@ -336,18 +336,20 @@ abstract class ResponseContext<RawResponse>
@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<RawResponse>
@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);

View file

@ -269,9 +269,9 @@ class Angel extends Routable {
Future<bool> 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);

View file

@ -196,17 +196,17 @@ class Service<Id, Data> extends Routable {
///
/// For example, `parseId<bool>` attempts to parse the value as a [bool].
static T parseId<T>(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;

View file

@ -104,9 +104,9 @@ class HttpResponseContext extends ResponseContext<HttpResponse> {
Converter<List<int>, List<int>> 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<HttpResponse> {
Converter<List<int>, List<int>> 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<HttpResponse> {
@override
void add(List<int> 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<HttpResponse> {
Converter<List<int>, List<int>> 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];
}

View file

@ -82,9 +82,9 @@ class Http2ResponseContext extends ResponseContext<ServerTransportStream> {
Converter<List<int>, List<int>> 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<ServerTransportStream> {
Converter<List<int>, List<int>> 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<ServerTransportStream> {
@override
void add(List<int> 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<ServerTransportStream> {
Converter<List<int>, List<int>> 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];
}

View file

@ -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;