From a54d60d47f674059f7251b347b3a911bcc33698d Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto <5731772+marandaneto@users.noreply.github.com> Date: Thu, 1 Dec 2022 10:35:28 +0100 Subject: [PATCH] Update dev deps (#1158) --- dart/example/pubspec.yaml | 2 +- dart/example_web/pubspec.yaml | 4 +- dio/pubspec.yaml | 1 - dio/test/mocks/mock_http_client_adapter.dart | 10 +++- dio/test/sentry_dio_client_adapter_test.dart | 37 +++++++----- dio/test/tracing_client_adapter_test.dart | 4 -- e2e_test/pubspec.yaml | 4 +- flutter/example/analysis_options.yaml | 2 +- .../integration_test/integration_test.dart | 10 ++-- flutter/example/lib/main.dart | 60 +++++++++++-------- flutter/example/lib/user_feedback_dialog.dart | 47 ++++++++------- flutter/example/pubspec.yaml | 6 +- min_version_test/pubspec.yaml | 2 +- 13 files changed, 104 insertions(+), 85 deletions(-) diff --git a/dart/example/pubspec.yaml b/dart/example/pubspec.yaml index 3b8fd30f44..2e5348a269 100644 --- a/dart/example/pubspec.yaml +++ b/dart/example/pubspec.yaml @@ -12,4 +12,4 @@ dependencies: path: ../../dart dev_dependencies: - lints: ^1.0.1 + lints: ^2.0.0 diff --git a/dart/example_web/pubspec.yaml b/dart/example_web/pubspec.yaml index 3ab1d596ab..1788065332 100644 --- a/dart/example_web/pubspec.yaml +++ b/dart/example_web/pubspec.yaml @@ -11,7 +11,7 @@ dependencies: path: ../../dart dev_dependencies: - build_runner: ^2.1.7 + build_runner: ^2.1.8 build_web_compilers: ^3.2.2 - lints: ^1.0.1 + lints: ^2.0.0 webdev: ^2.7.6 diff --git a/dio/pubspec.yaml b/dio/pubspec.yaml index 319cff0bf7..050eb3d5c9 100644 --- a/dio/pubspec.yaml +++ b/dio/pubspec.yaml @@ -18,4 +18,3 @@ dev_dependencies: test: ^1.21.1 coverage: ^1.3.0 mockito: ^5.1.0 - http: ^0.13.4 diff --git a/dio/test/mocks/mock_http_client_adapter.dart b/dio/test/mocks/mock_http_client_adapter.dart index 95dedd10a8..8f55d6b9d1 100644 --- a/dio/test/mocks/mock_http_client_adapter.dart +++ b/dio/test/mocks/mock_http_client_adapter.dart @@ -10,11 +10,14 @@ typedef MockFetchMethod = Future Function( Future? cancelFuture, ); +typedef MockCloseMethod = void Function({bool force}); + class MockHttpClientAdapter extends HttpClientAdapter with NoSuchMethodProvider { - MockHttpClientAdapter(this.mockFetchMethod); + MockHttpClientAdapter(this.mockFetchMethod, {this.mockCloseMethod}); final MockFetchMethod mockFetchMethod; + final MockCloseMethod? mockCloseMethod; @override Future fetch( @@ -24,4 +27,9 @@ class MockHttpClientAdapter extends HttpClientAdapter ) { return mockFetchMethod(options, requestStream, cancelFuture); } + + @override + void close({bool force = false}) { + return mockCloseMethod?.call(force: force); + } } diff --git a/dio/test/sentry_dio_client_adapter_test.dart b/dio/test/sentry_dio_client_adapter_test.dart index d81620ee3b..5fe1f406b1 100644 --- a/dio/test/sentry_dio_client_adapter_test.dart +++ b/dio/test/sentry_dio_client_adapter_test.dart @@ -1,6 +1,4 @@ import 'package:dio/dio.dart'; -import 'package:http/http.dart'; -import 'package:mockito/mockito.dart'; import 'package:sentry/sentry.dart'; import 'package:sentry_dio/src/sentry_dio_client_adapter.dart'; import 'package:test/test.dart'; @@ -47,16 +45,10 @@ void main() { }); test('close does get called for user defined client', () async { - final mockHub = MockHub(); + final client = createCloseClient(); + final sut = fixture.getSut(client: client); - final mockClient = CloseableMockClient(); - - final client = SentryHttpClient(client: mockClient, hub: mockHub); - client.close(); - - expect(mockHub.addBreadcrumbCalls.length, 0); - expect(mockHub.captureExceptionCalls.length, 0); - verify(mockClient.close()); + sut.close(force: true); }); test('no captured span if tracing disabled', () async { @@ -96,7 +88,18 @@ MockHttpClientAdapter createThrowingClient() { ); } -class CloseableMockClient extends Mock implements BaseClient {} +void _close({bool force = false}) { + expect(force, true); +} + +MockHttpClientAdapter createCloseClient() { + return MockHttpClientAdapter( + (_, __, ___) async { + return ResponseBody.fromString('', 200); + }, + mockCloseMethod: _close, + ); +} class Fixture { Dio getSut({ @@ -121,10 +124,12 @@ class Fixture { final MockHub hub = MockHub(); MockHttpClientAdapter getClient({int statusCode = 200, String? reason}) { - return MockHttpClientAdapter((options, _, __) async { - expect(options.uri, requestUri); - return ResponseBody.fromString('', statusCode); - }); + return MockHttpClientAdapter( + (options, _, __) async { + expect(options.uri, requestUri); + return ResponseBody.fromString('', statusCode); + }, + ); } } diff --git a/dio/test/tracing_client_adapter_test.dart b/dio/test/tracing_client_adapter_test.dart index 4251786c8b..8db5efb4cd 100644 --- a/dio/test/tracing_client_adapter_test.dart +++ b/dio/test/tracing_client_adapter_test.dart @@ -2,8 +2,6 @@ // The lint above is okay, because we're using another Sentry package import 'package:dio/dio.dart'; -import 'package:http/http.dart'; -import 'package:mockito/mockito.dart'; import 'package:sentry/sentry.dart'; import 'package:sentry/src/sentry_tracer.dart'; import 'package:sentry_dio/src/tracing_client_adapter.dart'; @@ -153,8 +151,6 @@ MockHttpClientAdapter createThrowingClient() { ); } -class CloseableMockClient extends Mock implements BaseClient {} - class Fixture { final _options = SentryOptions(dsn: fakeDsn); late Hub _hub; diff --git a/e2e_test/pubspec.yaml b/e2e_test/pubspec.yaml index f61847795a..806f641072 100644 --- a/e2e_test/pubspec.yaml +++ b/e2e_test/pubspec.yaml @@ -11,7 +11,7 @@ dependencies: sentry: path: ./../dart - http: ^0.13.3 + http: ^0.13.0 dev_dependencies: - lints: ^1.0.1 + lints: ^2.0.0 diff --git a/flutter/example/analysis_options.yaml b/flutter/example/analysis_options.yaml index 55e3702167..86b85ea02c 100644 --- a/flutter/example/analysis_options.yaml +++ b/flutter/example/analysis_options.yaml @@ -1,4 +1,4 @@ -include: package:pedantic/analysis_options.yaml +include: package:flutter_lints/flutter.yaml analyzer: errors: diff --git a/flutter/example/integration_test/integration_test.dart b/flutter/example/integration_test/integration_test.dart index 9889eb5371..918e1bb600 100644 --- a/flutter/example/integration_test/integration_test.dart +++ b/flutter/example/integration_test/integration_test.dart @@ -13,7 +13,7 @@ void main() { await tester.pumpWidget(SentryScreenshotWidget( child: DefaultAssetBundle( bundle: SentryAssetBundle(enableStructuredDataTracing: true), - child: MyApp(), + child: const MyApp(), ))); await tester.pumpAndSettle(); }); @@ -34,20 +34,20 @@ void main() { final event = SentryEvent(); final sentryId = await Sentry.captureEvent(event); - expect(sentryId != SentryId.empty(), true); + expect(sentryId != const SentryId.empty(), true); }); testWidgets('setup sentry and capture exception', (tester) async { await setupSentryAndApp(tester); try { - throw SentryException( + throw const SentryException( type: 'StarError', value: 'I have a bad feeling about this...'); } catch (exception, stacktrace) { final sentryId = await Sentry.captureException(exception, stackTrace: stacktrace); - expect(sentryId != SentryId.empty(), true); + expect(sentryId != const SentryId.empty(), true); } }); @@ -56,7 +56,7 @@ void main() { final sentryId = await Sentry.captureMessage('hello world!'); - expect(sentryId != SentryId.empty(), true); + expect(sentryId != const SentryId.empty(), true); }); testWidgets('setup sentry and capture user feedback', (tester) async { diff --git a/flutter/example/lib/main.dart b/flutter/example/lib/main.dart index c60642d02d..46665eadf2 100644 --- a/flutter/example/lib/main.dart +++ b/flutter/example/lib/main.dart @@ -1,3 +1,5 @@ +// ignore_for_file: library_private_types_in_public_api + import 'dart:async'; import 'dart:convert'; @@ -18,7 +20,7 @@ import 'package:sentry_logging/sentry_logging.dart'; const String _exampleDsn = 'https://e85b375ffb9f43cf8bdf9787768149e0@o447951.ingest.sentry.io/5428562'; -final _channel = const MethodChannel('example.flutter.sentry.io'); +const _channel = MethodChannel('example.flutter.sentry.io'); Future main() async { await setupSentry(() => runApp( @@ -26,7 +28,7 @@ Future main() async { child: SentryUserInteractionWidget( child: DefaultAssetBundle( bundle: SentryAssetBundle(enableStructuredDataTracing: true), - child: MyApp(), + child: const MyApp(), ), ), ), @@ -58,6 +60,8 @@ Future setupSentry(AppRunner appRunner) async { } class MyApp extends StatefulWidget { + const MyApp({Key? key}) : super(key: key); + @override _MyAppState createState() => _MyAppState(); } @@ -110,13 +114,13 @@ class MainScaffold extends StatelessWidget { onPressed: () { themeProvider.updatePrimatryColor(Colors.orange); }, - icon: Icon(Icons.circle, color: Colors.orange), + icon: const Icon(Icons.circle, color: Colors.orange), ), IconButton( onPressed: () { themeProvider.updatePrimatryColor(Colors.green); }, - icon: Icon(Icons.circle, color: Colors.lime), + icon: const Icon(Icons.circle, color: Colors.lime), ), ], ), @@ -130,7 +134,7 @@ class MainScaffold extends StatelessWidget { ), ElevatedButton( onPressed: () => tryCatch(), - key: Key('dart_try_catch'), + key: const Key('dart_try_catch'), child: const Text('Dart: try catch'), ), ElevatedButton( @@ -174,7 +178,7 @@ class MainScaffold extends StatelessWidget { ), ElevatedButton( onPressed: () => Future.delayed( - Duration(milliseconds: 100), + const Duration(milliseconds: 100), () => throw Exception('Throws in Future.delayed'), ), child: const Text('Throws in Future.delayed'), @@ -208,12 +212,13 @@ class MainScaffold extends StatelessWidget { child: const Text('Flutter: Load assets'), ), ElevatedButton( - key: Key('dio_web_request'), + key: const Key('dio_web_request'), onPressed: () async => await makeWebRequestWithDio(context), child: const Text('Dio: Web request'), ), ElevatedButton( onPressed: () { + // ignore: avoid_print print('A print breadcrumb'); Sentry.captureMessage('A message with a print() Breadcrumb'); }, @@ -242,7 +247,7 @@ class MainScaffold extends StatelessWidget { transaction.setTag('myTag', 'myValue'); transaction.setData('myExtra', 'myExtraValue'); - await Future.delayed(Duration(milliseconds: 50)); + await Future.delayed(const Duration(milliseconds: 50)); final span = transaction.startChild( 'childOfMyOp', @@ -251,29 +256,30 @@ class MainScaffold extends StatelessWidget { span.setTag('myNewTag', 'myNewValue'); span.setData('myNewData', 'myNewDataValue'); - await Future.delayed(Duration(milliseconds: 70)); + await Future.delayed(const Duration(milliseconds: 70)); - await span.finish(status: SpanStatus.resourceExhausted()); + await span.finish(status: const SpanStatus.resourceExhausted()); - await Future.delayed(Duration(milliseconds: 90)); + await Future.delayed(const Duration(milliseconds: 90)); final spanChild = span.startChild( 'childOfChildOfMyOp', description: 'childOfChildOfMyOp span', ); - await Future.delayed(Duration(milliseconds: 110)); + await Future.delayed(const Duration(milliseconds: 110)); spanChild.startChild( 'unfinishedChild', description: 'I wont finish', ); - await spanChild.finish(status: SpanStatus.internalError()); + await spanChild.finish( + status: const SpanStatus.internalError()); - await Future.delayed(Duration(milliseconds: 50)); + await Future.delayed(const Duration(milliseconds: 50)); - await transaction.finish(status: SpanStatus.ok()); + await transaction.finish(status: const SpanStatus.ok()); }, child: const Text('Capture transaction'), ), @@ -282,7 +288,7 @@ class MainScaffold extends StatelessWidget { Sentry.captureMessage( 'This message has an attachment', withScope: (scope) { - final txt = 'Lorem Ipsum dolar sit amet'; + const txt = 'Lorem Ipsum dolar sit amet'; scope.addAttachment( SentryAttachment.fromIntList( utf8.encode(txt), @@ -474,6 +480,8 @@ int loop(int val) { } class SecondaryScaffold extends StatelessWidget { + const SecondaryScaffold({Key? key}) : super(key: key); + static Future openSecondaryScaffold(BuildContext context) { return Navigator.push( context, @@ -481,7 +489,7 @@ class SecondaryScaffold extends StatelessWidget { settings: const RouteSettings(name: 'SecondaryScaffold', arguments: 'foobar'), builder: (context) { - return SecondaryScaffold(); + return const SecondaryScaffold(); }, ), ); @@ -537,12 +545,12 @@ Future makeWebRequest(BuildContext context) async { // In case of an exception, let it get caught and reported to Sentry final response = await client.get(Uri.parse('https://flutter.dev/')); - await transaction.finish(status: SpanStatus.ok()); + await transaction.finish(status: const SpanStatus.ok()); await showDialog( context: context, // gets tracked if using SentryNavigatorObserver - routeSettings: RouteSettings( + routeSettings: const RouteSettings( name: 'flutter.dev dialog', ), builder: (context) { @@ -584,10 +592,10 @@ Future makeWebRequestWithDio(BuildContext context) async { Response? response; try { response = await dio.get('https://flutter.dev/'); - span.status = SpanStatus.ok(); + span.status = const SpanStatus.ok(); } catch (exception, stackTrace) { span.throwable = exception; - span.status = SpanStatus.internalError(); + span.status = const SpanStatus.internalError(); await Sentry.captureException(exception, stackTrace: stackTrace); } finally { await span.finish(); @@ -596,7 +604,7 @@ Future makeWebRequestWithDio(BuildContext context) async { await showDialog( context: context, // gets tracked if using SentryNavigatorObserver - routeSettings: RouteSettings( + routeSettings: const RouteSettings( name: 'flutter.dev dialog', ), builder: (context) { @@ -628,12 +636,12 @@ Future showDialogWithTextAndImage(BuildContext context) async { await showDialog( context: context, // gets tracked if using SentryNavigatorObserver - routeSettings: RouteSettings( + routeSettings: const RouteSettings( name: 'AssetBundle dialog', ), builder: (context) { return AlertDialog( - title: Text('Asset Example'), + title: const Text('Asset Example'), content: SingleChildScrollView( child: Column( mainAxisSize: MainAxisSize.min, @@ -646,13 +654,13 @@ Future showDialogWithTextAndImage(BuildContext context) async { actions: [ MaterialButton( onPressed: () => Navigator.pop(context), - child: Text('Close'), + child: const Text('Close'), ) ], ); }, ); - await transaction.finish(status: SpanStatus.ok()); + await transaction.finish(status: const SpanStatus.ok()); } class ThemeProvider extends ChangeNotifier { diff --git a/flutter/example/lib/user_feedback_dialog.dart b/flutter/example/lib/user_feedback_dialog.dart index 7fdc077c94..6eac0db7ba 100644 --- a/flutter/example/lib/user_feedback_dialog.dart +++ b/flutter/example/lib/user_feedback_dialog.dart @@ -1,3 +1,5 @@ +// ignore_for_file: library_private_types_in_public_api + import 'package:flutter/material.dart'; import 'package:sentry_flutter/sentry_flutter.dart'; @@ -34,7 +36,7 @@ class _UserFeedbackDialogState extends State { textAlign: TextAlign.center, style: Theme.of(context).textTheme.headline6, ), - SizedBox(height: 4), + const SizedBox(height: 4), Text( 'Our team has been notified. ' "If you'd like to help, tell us what happened below.", @@ -44,46 +46,46 @@ class _UserFeedbackDialogState extends State { .subtitle1 ?.copyWith(color: Colors.grey), ), - Divider(height: 24), + const Divider(height: 24), TextField( - key: ValueKey('sentry_name_textfield'), - decoration: InputDecoration( + key: const ValueKey('sentry_name_textfield'), + decoration: const InputDecoration( border: OutlineInputBorder(), hintText: 'Name', ), controller: nameController, keyboardType: TextInputType.text, ), - SizedBox(height: 8), + const SizedBox(height: 8), TextField( - key: ValueKey('sentry_email_textfield'), - decoration: InputDecoration( + key: const ValueKey('sentry_email_textfield'), + decoration: const InputDecoration( border: OutlineInputBorder(), hintText: 'E-Mail', ), controller: emailController, keyboardType: TextInputType.emailAddress, ), - SizedBox(height: 8), + const SizedBox(height: 8), TextField( - key: ValueKey('sentry_comment_textfield'), + key: const ValueKey('sentry_comment_textfield'), minLines: 5, maxLines: null, - decoration: InputDecoration( + decoration: const InputDecoration( border: OutlineInputBorder(), hintText: 'What happened?', ), controller: commentController, keyboardType: TextInputType.multiline, ), - SizedBox(height: 8), + const SizedBox(height: 8), const _PoweredBySentryMessage(), ], ), ), actions: [ ElevatedButton( - key: ValueKey('sentry_submit_feedback_button'), + key: const ValueKey('sentry_submit_feedback_button'), onPressed: () async { final feedback = SentryUserFeedback( eventId: widget.eventId, @@ -92,15 +94,16 @@ class _UserFeedbackDialogState extends State { name: nameController.text, ); await _submitUserFeedback(feedback); + // ignore: use_build_context_synchronously Navigator.pop(context); }, - child: Text('Submit Crash Report')), + child: const Text('Submit Crash Report')), TextButton( - key: ValueKey('sentry_close_button'), + key: const ValueKey('sentry_close_button'), onPressed: () { Navigator.pop(context); }, - child: Text('Close'), + child: const Text('Close'), ) ], ); @@ -123,8 +126,8 @@ class _PoweredBySentryMessage extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.end, mainAxisSize: MainAxisSize.min, children: [ - Text('Crash reports powered by'), - SizedBox(width: 8), + const Text('Crash reports powered by'), + const SizedBox(width: 8), SizedBox( height: 30, child: _SentryLogo(), @@ -141,13 +144,13 @@ class _SentryLogo extends StatelessWidget { var color = Colors.white; final brightenss = Theme.of(context).brightness; if (brightenss == Brightness.light) { - color = Color(0xff362d59).withOpacity(1.0); + color = const Color(0xff362d59).withOpacity(1.0); } return FittedBox( fit: BoxFit.contain, child: CustomPaint( - size: Size(222, 66), + size: const Size(222, 66), painter: _SentryLogoCustomPainter(color), ), ); @@ -448,9 +451,9 @@ class _SentryLogoCustomPainter extends CustomPainter { size.height * 0.3378788); path_0.close(); - final paint_0_fill = Paint()..style = PaintingStyle.fill; - paint_0_fill.color = color; - canvas.drawPath(path_0, paint_0_fill); + final paint0Fill = Paint()..style = PaintingStyle.fill; + paint0Fill.color = color; + canvas.drawPath(path_0, paint0Fill); } @override diff --git a/flutter/example/pubspec.yaml b/flutter/example/pubspec.yaml index 932b06af70..6d9d3a2fa0 100644 --- a/flutter/example/pubspec.yaml +++ b/flutter/example/pubspec.yaml @@ -15,15 +15,15 @@ dependencies: sentry_flutter: sentry_dio: sentry_logging: - universal_platform: ^1.0.0-nullsafety + universal_platform: ^1.0.0 feedback: ^2.0.0 provider: ^6.0.0 dio: ^4.0.0 - logging: ^1.0.2 + logging: ^1.0.0 package_info_plus: ^3.0.0 dev_dependencies: - pedantic: ^1.11.1 + flutter_lints: ^2.0.0 sentry_dart_plugin: ^1.0.0-beta.1 integration_test: sdk: flutter diff --git a/min_version_test/pubspec.yaml b/min_version_test/pubspec.yaml index f82985aa50..368deb46d7 100644 --- a/min_version_test/pubspec.yaml +++ b/min_version_test/pubspec.yaml @@ -35,7 +35,7 @@ dependencies: sentry_dio: sentry_logging: dio: ^4.0.0 - logging: ^1.0.2 + logging: ^1.0.0 dev_dependencies: flutter_test: