Fixed framework analysis warnings
This commit is contained in:
parent
5bea55d2c0
commit
4a48000bc3
15 changed files with 36 additions and 33 deletions
|
@ -345,7 +345,7 @@ class HookedService<Id, Data, T extends Service<Id, Data>>
|
|||
.then((after) => after.result as Data);
|
||||
}
|
||||
|
||||
return inner.create(before.data!, localParams).then((result) {
|
||||
return inner.create(before.data as Data, localParams).then((result) {
|
||||
return afterCreated
|
||||
._emit(HookedServiceEvent(true, _getRequest(params),
|
||||
_getResponse(params), inner, HookedServiceEvent.created,
|
||||
|
@ -374,7 +374,7 @@ class HookedService<Id, Data, T extends Service<Id, Data>>
|
|||
.then((after) => after.result as Data);
|
||||
}
|
||||
|
||||
return inner.modify(id, before.data!, localParams).then((result) {
|
||||
return inner.modify(id, before.data as Data, localParams).then((result) {
|
||||
return afterModified
|
||||
._emit(HookedServiceEvent(true, _getRequest(params),
|
||||
_getResponse(params), inner, HookedServiceEvent.created,
|
||||
|
@ -403,7 +403,7 @@ class HookedService<Id, Data, T extends Service<Id, Data>>
|
|||
.then((after) => after.result as Data);
|
||||
}
|
||||
|
||||
return inner.update(id, before.data!, localParams).then((result) {
|
||||
return inner.update(id, before.data as Data, localParams).then((result) {
|
||||
return afterUpdated
|
||||
._emit(HookedServiceEvent(true, _getRequest(params),
|
||||
_getResponse(params), inner, HookedServiceEvent.updated,
|
||||
|
@ -546,6 +546,7 @@ class HookedServiceEvent<Id, Data, T extends Service<Id, Data>> {
|
|||
HookedServiceEvent(this._isAfter, this._request, this._response, this.service,
|
||||
this._eventName,
|
||||
{Id? id, this.data, Map<String, dynamic>? params, this.result}) {
|
||||
//_data = data;
|
||||
_id = id;
|
||||
_params = params ?? {};
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ class HostnameSyntaxParser {
|
|||
FormatException _formatExc(String message) {
|
||||
var span = _scanner.lastSpan ?? _scanner.emptySpan;
|
||||
return FormatException(
|
||||
'${span.start.toolString}: $message\n' + span.highlight(color: true));
|
||||
'${span.start.toolString}: $message\n${span.highlight(color: true)}');
|
||||
}
|
||||
|
||||
RegExp parse() {
|
||||
|
@ -38,7 +38,7 @@ class HostnameSyntaxParser {
|
|||
if (_scanner.scan('.')) {
|
||||
var subPart = _parseHostnamePart(shouldThrow: false);
|
||||
while (subPart.isNotEmpty) {
|
||||
part += '\\.' + subPart;
|
||||
part += '\\.$subPart';
|
||||
if (_scanner.scan('.')) {
|
||||
subPart = _parseHostnamePart(shouldThrow: false);
|
||||
} else {
|
||||
|
|
|
@ -169,10 +169,9 @@ InjectionRequest preInject(Function handler, Reflector reflector) {
|
|||
var name = parameter.name;
|
||||
var type = parameter.type.reflectedType;
|
||||
|
||||
var _parameter = reflector.reflectType(Parameter);
|
||||
|
||||
var p = parameter.annotations
|
||||
.firstWhereOrNull((m) => m.type.isAssignableTo(_parameter))
|
||||
.firstWhereOrNull(
|
||||
(m) => m.type.isAssignableTo(reflector.reflectType(Parameter)))
|
||||
?.reflectee as Parameter?;
|
||||
//print(p);
|
||||
if (p != null) {
|
||||
|
|
|
@ -388,7 +388,7 @@ class Angel extends Routable {
|
|||
}
|
||||
|
||||
static const String _reflectionErrorMessage =
|
||||
ThrowingReflector.defaultErrorMessage + ' ' + _reflectionInfo;
|
||||
'${ThrowingReflector.defaultErrorMessage} $_reflectionInfo';
|
||||
|
||||
static const String _reflectionInfo =
|
||||
'Features like controllers, constructor dependency injection, and `ioc` require reflection, '
|
||||
|
@ -412,8 +412,7 @@ class Angel extends Routable {
|
|||
|
||||
if (reflector is EmptyReflector || reflector is ThrowingReflector) {
|
||||
var msg =
|
||||
'No `reflector` was passed to the Angel constructor, so reflection will not be available.\n' +
|
||||
_reflectionInfo;
|
||||
'No `reflector` was passed to the Angel constructor, so reflection will not be available.\n$_reflectionInfo';
|
||||
this.logger.warning(msg);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import 'package:angel3_framework/http.dart';
|
|||
import 'package:angel3_mock_request/angel3_mock_request.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
final Uri ENDPOINT = Uri.parse('http://example.com/accept');
|
||||
final Uri endpoint = Uri.parse('http://example.com/accept');
|
||||
|
||||
void main() {
|
||||
test('no content type', () async {
|
||||
|
@ -61,7 +61,7 @@ Future<RequestContext> acceptContentTypes(
|
|||
[Iterable<String> contentTypes = const []]) {
|
||||
var headerString =
|
||||
contentTypes.isEmpty ? ContentType.text : contentTypes.join(',');
|
||||
var rq = MockHttpRequest('GET', ENDPOINT, persistentConnection: false);
|
||||
var rq = MockHttpRequest('GET', endpoint, persistentConnection: false);
|
||||
rq.headers.set('accept', headerString);
|
||||
rq.close();
|
||||
var app = Angel(reflector: MirrorsReflector());
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import 'dart:io';
|
||||
import 'package:io/ansi.dart';
|
||||
import '404_hole_test.dart' as hole404;
|
||||
import 'http_404_hole_test.dart' as hole404;
|
||||
import 'accepts_test.dart' as accepts;
|
||||
import 'anonymous_service_test.dart' as anonymous_service;
|
||||
import 'body_test.dart' as body;
|
||||
|
@ -32,7 +32,7 @@ import 'package:test/test.dart';
|
|||
/// For running with coverage
|
||||
void main() {
|
||||
print(cyan.wrap('Running tests on ${Platform.version}'));
|
||||
group('404_hole', hole404.main);
|
||||
group('http_404_hole', hole404.main);
|
||||
group('accepts', accepts.main);
|
||||
group('anonymous service', anonymous_service.main);
|
||||
group('body', body.main);
|
||||
|
|
|
@ -29,12 +29,12 @@ class BookService extends Service {
|
|||
}
|
||||
|
||||
void incrementTodoTimes(e) {
|
||||
IncrementService.TIMES++;
|
||||
IncrementService.times++;
|
||||
}
|
||||
|
||||
@Hooks(before: [incrementTodoTimes])
|
||||
class IncrementService extends Service {
|
||||
static int TIMES = 0;
|
||||
static int times = 0;
|
||||
|
||||
@override
|
||||
@Hooks(after: [incrementTodoTimes])
|
||||
|
|
|
@ -11,8 +11,8 @@ import 'package:test/test.dart';
|
|||
|
||||
import 'common.dart';
|
||||
|
||||
final String TEXT = 'make your bed';
|
||||
final String OVER = 'never';
|
||||
final String sampleText = 'make your bed';
|
||||
final String sampleOver = 'never';
|
||||
|
||||
void main() {
|
||||
late Angel app;
|
||||
|
@ -25,7 +25,7 @@ void main() {
|
|||
client = http.Client();
|
||||
|
||||
// Inject some todos
|
||||
app.container.registerSingleton(Todo(text: TEXT, over: OVER));
|
||||
app.container.registerSingleton(Todo(text: sampleText, over: sampleOver));
|
||||
app.container.registerFactory<Future<Foo>>((container) async {
|
||||
var req = container.make<RequestContext>();
|
||||
var text = await utf8.decoder.bind(req.body!).join();
|
||||
|
@ -79,13 +79,13 @@ void main() {
|
|||
test('make in route', () async {
|
||||
var response = await client.get(Uri.parse('$url/errands3'));
|
||||
var text = await json.decode(response.body) as String?;
|
||||
expect(text, equals(TEXT));
|
||||
expect(text, equals(sampleText));
|
||||
});
|
||||
|
||||
test('make in controller', () async {
|
||||
var response = await client.get(Uri.parse('$url/errands4'));
|
||||
var text = await json.decode(response.body) as String?;
|
||||
expect(text, equals(TEXT));
|
||||
expect(text, equals(sampleText));
|
||||
});
|
||||
|
||||
test('resolve from future in controller', () async {
|
||||
|
@ -103,8 +103,8 @@ void main() {
|
|||
void validateTodoSingleton(response) {
|
||||
var todo = json.decode(response.body.toString()) as Map;
|
||||
expect(todo['id'], equals(null));
|
||||
expect(todo['text'], equals(TEXT));
|
||||
expect(todo['over'], equals(OVER));
|
||||
expect(todo['text'], equals(sampleText));
|
||||
expect(todo['over'], equals(sampleOver));
|
||||
}
|
||||
|
||||
@Expose('/errands2')
|
||||
|
|
|
@ -5,7 +5,7 @@ import 'package:angel3_framework/http.dart';
|
|||
import 'package:angel3_mock_request/angel3_mock_request.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
final Uri ENDPOINT = Uri.parse('http://example.com');
|
||||
final Uri endpoint = Uri.parse('http://example.com');
|
||||
|
||||
void main() {
|
||||
test('single extension', () async {
|
||||
|
@ -25,7 +25,7 @@ void main() {
|
|||
}
|
||||
|
||||
Future<RequestContext> makeRequest(String path) {
|
||||
var rq = MockHttpRequest('GET', ENDPOINT.replace(path: path))..close();
|
||||
var rq = MockHttpRequest('GET', endpoint.replace(path: path))..close();
|
||||
var app = Angel(reflector: MirrorsReflector());
|
||||
var http = AngelHttp(app);
|
||||
return http.createRequestContext(rq, rq.response);
|
||||
|
|
|
@ -105,9 +105,9 @@ void main() {
|
|||
test('metadata', () async {
|
||||
final service = HookedService(IncrementService())..addHooks(app);
|
||||
expect(service.inner, isNot(const IsInstanceOf<MapService>()));
|
||||
IncrementService.TIMES = 0;
|
||||
IncrementService.times = 0;
|
||||
await service.index();
|
||||
expect(IncrementService.TIMES, equals(2));
|
||||
expect(IncrementService.times, equals(2));
|
||||
});
|
||||
|
||||
test('inject request + response', () async {
|
||||
|
|
|
@ -24,7 +24,7 @@ class Http2Client extends BaseClient {
|
|||
Header.ascii(
|
||||
':path',
|
||||
request.url.path +
|
||||
(request.url.hasQuery ? ('?' + request.url.query) : '')),
|
||||
(request.url.hasQuery ? ('?${request.url.query}') : '')),
|
||||
Header.ascii(':scheme', request.url.scheme),
|
||||
];
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ void prettyLog(LogRecord record) {
|
|||
|
||||
if (record.error != null) {
|
||||
var err = record.error;
|
||||
print(code.wrap(record.toString() + '\n'));
|
||||
print(code.wrap('$record\n'));
|
||||
print(code.wrap(err.toString()));
|
||||
|
||||
if (record.stackTrace != null) {
|
||||
|
|
|
@ -127,7 +127,7 @@ void main() {
|
|||
|
||||
group('getHandlerResult', () {
|
||||
test('return request handler', () async {
|
||||
var handler = (req, res) => (req, res) async {
|
||||
handler(req, res) => (req, res) async {
|
||||
return 2;
|
||||
};
|
||||
var r = await app.getHandlerResult(handler, req, res);
|
||||
|
@ -142,12 +142,12 @@ void main() {
|
|||
|
||||
group('executeHandler', () {
|
||||
test('return Stream', () async {
|
||||
var handler = (req, res) => Stream.fromIterable([2, 3]);
|
||||
handler(req, res) => Stream.fromIterable([2, 3]);
|
||||
expect(await app.executeHandler(handler, req, res), isFalse);
|
||||
});
|
||||
|
||||
test('end response', () async {
|
||||
var handler = (req, ResponseContext res) => res.close();
|
||||
handler(req, ResponseContext res) => res.close();
|
||||
expect(await app.executeHandler(handler, req, res), isFalse);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import 'package:angel3_framework/angel3_framework.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:quiver/core.dart';
|
||||
|
||||
void main() {
|
||||
MapService inner;
|
||||
|
@ -77,4 +78,7 @@ class Todo {
|
|||
|
||||
@override
|
||||
String toString() => '$id:$text($complete)';
|
||||
|
||||
@override
|
||||
int get hashCode => hash2(text.hashCode, complete.hashCode);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue