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; Converter<List<int>, List<int>> encoder;
String key = encodingName; String key = encodingName;
if (res.encoders.containsKey(encodingName)) if (res.encoders.containsKey(encodingName)) {
encoder = res.encoders[encodingName]; encoder = res.encoders[encodingName];
else if (encodingName == '*') { } else if (encodingName == '*') {
encoder = res.encoders[key = res.encoders.keys.first]; 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)) { if (req.params.containsKey(requirement)) {
return req.params[requirement]; return req.params[requirement];
} else if ((propFromApp = req.app.findProperty(requirement)) != null) } else if ((propFromApp = req.app.findProperty(requirement)) != null) {
return propFromApp; return propFromApp;
else if (injection.optional.contains(requirement)) } else if (injection.optional.contains(requirement)) {
return null; return null;
else if (throwOnUnresolved) { } else if (throwOnUnresolved) {
throw ArgumentError( throw ArgumentError(
"Cannot resolve parameter '$requirement' within handler."); "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) { bool Function(Map<String, dynamic>) _matchesId(id) {
return (Map<String, dynamic> item) { return (Map<String, dynamic> item) {
if (item['id'] == null) if (item['id'] == null) {
return false; return false;
else if (autoIdAndDateFields != false) { } else if (autoIdAndDateFields != false) {
return item['id'] == id?.toString(); return item['id'] == id?.toString();
} else { } else {
return item['id'] == id; return item['id'] == id;
@ -56,9 +56,9 @@ class MapService extends Service<String, Map<String, dynamic>> {
return Future.value(items.where((item) { return Future.value(items.where((item) {
for (var key in query.keys) { for (var key in query.keys) {
if (!item.containsKey(key)) if (!item.containsKey(key)) {
return false; return false;
else if (item[key] != query[key]) return false; } else if (item[key] != query[key]) return false;
} }
return true; return true;

View file

@ -209,9 +209,9 @@ abstract class RequestContext<RawRequest> {
_acceptHeaderCache ??= headers.value('accept'); _acceptHeaderCache ??= headers.value('accept');
if (_acceptHeaderCache == null) if (_acceptHeaderCache == null) {
return false; return false;
else if (strict != true && _acceptHeaderCache.contains('*/*')) { } else if (strict != true && _acceptHeaderCache.contains('*/*')) {
return true; return true;
} else { } else {
return _acceptHeaderCache.contains(contentTypeString); return _acceptHeaderCache.contains(contentTypeString);

View file

@ -336,18 +336,20 @@ abstract class ResponseContext<RawResponse>
@override @override
void addError(Object error, [StackTrace stackTrace]) { void addError(Object error, [StackTrace stackTrace]) {
if (_done?.isCompleted == false) if (_done?.isCompleted == false) {
_done.completeError(error, stackTrace); _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. /// Writes data to the response.
void write(value, {Encoding encoding}) { void write(value, {Encoding encoding}) {
encoding ??= utf8; encoding ??= utf8;
if (!isOpen && isBuffered) if (!isOpen && isBuffered) {
throw closed(); throw closed();
else if (!isBuffered) { } else if (!isBuffered) {
add(encoding.encode(value.toString())); add(encoding.encode(value.toString()));
} else { } else {
buffer.add(encoding.encode(value.toString())); buffer.add(encoding.encode(value.toString()));
@ -356,9 +358,9 @@ abstract class ResponseContext<RawResponse>
@override @override
void writeCharCode(int charCode) { void writeCharCode(int charCode) {
if (!isOpen && isBuffered) if (!isOpen && isBuffered) {
throw closed(); throw closed();
else if (!isBuffered) { } else if (!isBuffered) {
add([charCode]); add([charCode]);
} else { } else {
buffer.addByte(charCode); buffer.addByte(charCode);

View file

@ -269,9 +269,9 @@ class Angel extends Routable {
Future<bool> executeHandler( Future<bool> executeHandler(
handler, RequestContext req, ResponseContext res) { handler, RequestContext req, ResponseContext res) {
return getHandlerResult(handler, req, res).then((result) { return getHandlerResult(handler, req, res).then((result) {
if (result == null) if (result == null) {
return false; return false;
else if (result is bool) { } else if (result is bool) {
return result; return result;
} else if (result != null) { } else if (result != null) {
return res.serialize(result); 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]. /// For example, `parseId<bool>` attempts to parse the value as a [bool].
static T parseId<T>(id) { static T parseId<T>(id) {
if (id == 'null' || id == null) if (id == 'null' || id == null) {
return null; return null;
else if (T == String) } else if (T == String) {
return id.toString() as T; return id.toString() as T;
else if (T == int) } else if (T == int) {
return int.parse(id.toString()) as T; return int.parse(id.toString()) as T;
else if (T == bool) } else if (T == bool) {
return (id == true || id?.toString() == 'true') as T; return (id == true || id?.toString() == 'true') as T;
else if (T == double) } else if (T == double) {
return double.parse(id.toString()) as T; return double.parse(id.toString()) as T;
else if (T == num) { } else if (T == num) {
return num.parse(id.toString()) as T; return num.parse(id.toString()) as T;
} else { } else {
return id as T; return id as T;

View file

@ -104,9 +104,9 @@ class HttpResponseContext extends ResponseContext<HttpResponse> {
Converter<List<int>, List<int>> encoder; Converter<List<int>, List<int>> encoder;
String key = encodingName; String key = encodingName;
if (encoders.containsKey(encodingName)) if (encoders.containsKey(encodingName)) {
encoder = encoders[encodingName]; encoder = encoders[encodingName];
else if (encodingName == '*') { } else if (encodingName == '*') {
encoder = encoders[key = encoders.keys.first]; encoder = encoders[key = encoders.keys.first];
} }
@ -138,9 +138,9 @@ class HttpResponseContext extends ResponseContext<HttpResponse> {
Converter<List<int>, List<int>> encoder; Converter<List<int>, List<int>> encoder;
String key = encodingName; String key = encodingName;
if (encoders.containsKey(encodingName)) if (encoders.containsKey(encodingName)) {
encoder = encoders[encodingName]; encoder = encoders[encodingName];
else if (encodingName == '*') { } else if (encodingName == '*') {
encoder = encoders[key = encoders.keys.first]; encoder = encoders[key = encoders.keys.first];
} }
@ -157,9 +157,9 @@ class HttpResponseContext extends ResponseContext<HttpResponse> {
@override @override
void add(List<int> data) { void add(List<int> data) {
if (_isClosed && isBuffered) if (_isClosed && isBuffered) {
throw ResponseContext.closed(); throw ResponseContext.closed();
else if (!isBuffered) { } else if (!isBuffered) {
if (!_isClosed) { if (!_isClosed) {
_openStream(); _openStream();
@ -169,9 +169,9 @@ class HttpResponseContext extends ResponseContext<HttpResponse> {
Converter<List<int>, List<int>> encoder; Converter<List<int>, List<int>> encoder;
String key = encodingName; String key = encodingName;
if (encoders.containsKey(encodingName)) if (encoders.containsKey(encodingName)) {
encoder = encoders[encodingName]; encoder = encoders[encodingName];
else if (encodingName == '*') { } else if (encodingName == '*') {
encoder = encoders[key = encoders.keys.first]; encoder = encoders[key = encoders.keys.first];
} }

View file

@ -82,9 +82,9 @@ class Http2ResponseContext extends ResponseContext<ServerTransportStream> {
Converter<List<int>, List<int>> encoder; Converter<List<int>, List<int>> encoder;
String key = encodingName; String key = encodingName;
if (encoders.containsKey(encodingName)) if (encoders.containsKey(encodingName)) {
encoder = encoders[encodingName]; encoder = encoders[encodingName];
else if (encodingName == '*') { } else if (encodingName == '*') {
encoder = encoders[key = encoders.keys.first]; encoder = encoders[key = encoders.keys.first];
} }
@ -142,9 +142,9 @@ class Http2ResponseContext extends ResponseContext<ServerTransportStream> {
Converter<List<int>, List<int>> encoder; Converter<List<int>, List<int>> encoder;
String key = encodingName; String key = encodingName;
if (encoders.containsKey(encodingName)) if (encoders.containsKey(encodingName)) {
encoder = encoders[encodingName]; encoder = encoders[encodingName];
else if (encodingName == '*') { } else if (encodingName == '*') {
encoder = encoders[key = encoders.keys.first]; encoder = encoders[key = encoders.keys.first];
} }
@ -161,9 +161,9 @@ class Http2ResponseContext extends ResponseContext<ServerTransportStream> {
@override @override
void add(List<int> data) { void add(List<int> data) {
if (!isOpen && isBuffered) if (!isOpen && isBuffered) {
throw ResponseContext.closed(); throw ResponseContext.closed();
else if (!isBuffered) { } else if (!isBuffered) {
_openStream(); _openStream();
if (!_isClosed) { if (!_isClosed) {
@ -173,9 +173,9 @@ class Http2ResponseContext extends ResponseContext<ServerTransportStream> {
Converter<List<int>, List<int>> encoder; Converter<List<int>, List<int>> encoder;
String key = encodingName; String key = encodingName;
if (encoders.containsKey(encodingName)) if (encoders.containsKey(encodingName)) {
encoder = encoders[encodingName]; encoder = encoders[encodingName];
else if (encodingName == '*') { } else if (encodingName == '*') {
encoder = encoders[key = encoders.keys.first]; encoder = encoders[key = encoders.keys.first];
} }

View file

@ -20,15 +20,15 @@ void prettyLog(LogRecord record) {
/// Chooses a color based on the logger [level]. /// Chooses a color based on the logger [level].
AnsiCode chooseLogColor(Level level) { AnsiCode chooseLogColor(Level level) {
if (level == Level.SHOUT) if (level == Level.SHOUT) {
return backgroundRed; return backgroundRed;
else if (level == Level.SEVERE) } else if (level == Level.SEVERE) {
return red; return red;
else if (level == Level.WARNING) } else if (level == Level.WARNING) {
return yellow; return yellow;
else if (level == Level.INFO) } else if (level == Level.INFO) {
return cyan; return cyan;
else if (level == Level.CONFIG || } else if (level == Level.CONFIG ||
level == Level.FINE || level == Level.FINE ||
level == Level.FINER || level == Level.FINER ||
level == Level.FINEST) return lightGray; level == Level.FINEST) return lightGray;