Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable strict mode for all SDKs but dart #1163

Merged
merged 6 commits into from
Dec 9, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions dio/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
include: package:lints/recommended.yaml

analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
language:
strict-casts: true
strict-inference: true
marandaneto marked this conversation as resolved.
Show resolved Hide resolved
strict-raw-types: true
errors:
# treat missing required parameters as a warning (not a hint)
Expand Down
4 changes: 4 additions & 0 deletions flutter/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
include: package:flutter_lints/flutter.yaml

analyzer:
language:
strict-casts: true
strict-inference: true
strict-raw-types: true
errors:
# treat missing required parameters as a warning (not a hint)
missing_required_param: error
Expand Down
6 changes: 3 additions & 3 deletions flutter/lib/src/integrations/load_contexts_integration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ class _LoadContextsIntegrationEventProcessor extends EventProcessor {
@override
FutureOr<SentryEvent?> apply(SentryEvent event, {hint}) async {
try {
final loadContexts = await _channel.invokeMethod('loadContexts');
final infos = Map<String, dynamic>.from(
await (_channel.invokeMethod('loadContexts')),
);
loadContexts is Map<String, dynamic> ? loadContexts : {});
final contextsMap = infos['contexts'] as Map?;
if (contextsMap != null && contextsMap.isNotEmpty) {
final contexts = Contexts.fromJson(
Expand Down Expand Up @@ -138,7 +138,7 @@ class _LoadContextsIntegrationEventProcessor extends EventProcessor {
final breadcrumbsList = infos['breadcrumbs'] as List?;
if (breadcrumbsList != null && breadcrumbsList.isNotEmpty) {
final breadcrumbs = event.breadcrumbs ?? [];
final newBreadcrumbs = List<Map>.from(breadcrumbsList);
final newBreadcrumbs = List<Map<String, dynamic>>.from(breadcrumbsList);

for (final breadcrumb in newBreadcrumbs) {
final newBreadcrumb = Map<String, dynamic>.from(breadcrumb);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ class _LoadImageListIntegrationEventProcessor extends EventProcessor {
try {
// we call on every event because the loaded image list is cached
// and it could be changed on the Native side.
final loadImageList = await _channel.invokeMethod('loadImageList');
final imageList = List<Map<dynamic, dynamic>>.from(
await _channel.invokeMethod('loadImageList'),
loadImageList is List<Map<dynamic, dynamic>> ? loadImageList : [],
);
return copyWithDebugImages(event, imageList);
} catch (exception, stackTrace) {
Expand Down
1 change: 1 addition & 0 deletions flutter/lib/src/sentry_asset_bundle.dart
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ class SentryAssetBundle implements AssetBundle {

Future<ImmutableBuffer> _loadBuffer(String key) async {
try {
// ignore: return_of_invalid_type
return (_bundle as dynamic).loadBuffer(key);
} on NoSuchMethodError catch (_) {
// The loadBuffer method exists as of Flutter greater than 3.1
Expand Down
10 changes: 5 additions & 5 deletions flutter/lib/src/sentry_native_channel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ class NativeAppStart {

factory NativeAppStart.fromJson(Map<String, dynamic> json) {
return NativeAppStart(
json['appStartTime'],
json['isColdStart'],
json['appStartTime'] as double,
json['isColdStart'] as bool,
);
}
}
Expand All @@ -153,9 +153,9 @@ class NativeFrames {

factory NativeFrames.fromJson(Map<String, dynamic> json) {
return NativeFrames(
json['totalFrames'],
json['slowFrames'],
json['frozenFrames'],
json['totalFrames'] as int,
json['slowFrames'] as int,
json['frozenFrames'] as int,
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void main() {

final throwable = exception ?? StateError('error');
final details = FlutterErrorDetails(
exception: throwable,
exception: throwable as Object,
silent: silent,
context: DiagnosticsNode.message('while handling a gesture'),
library: 'sentry',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void main() {
'attachThreads': false,
'autoSessionTrackingIntervalMillis': 30000,
'dist': null,
'integrations': [],
'integrations': <String>[],
'packages': [
{'name': 'pub:sentry', 'version': sdkVersion}
],
Expand Down Expand Up @@ -149,7 +149,7 @@ void main() {
final options = createOptions();
await sut.call(NoOpHub(), options);

expect(options.sdk.integrations, []);
expect(options.sdk.integrations, <String>[]);

channel.setMethodCallHandler(null);
});
Expand Down
2 changes: 2 additions & 0 deletions flutter/test/mocks.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: inference_failure_on_function_return_type

import 'dart:async';

import 'package:flutter/services.dart';
Expand Down
2 changes: 1 addition & 1 deletion flutter/test/sentry_flutter_util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:sentry_flutter/src/file_system_transport.dart';

void testTransport({
required Transport transport,
required hasFileSystemTransport,
required bool hasFileSystemTransport,
}) {
expect(
transport is FileSystemTransport,
Expand Down
2 changes: 2 additions & 0 deletions flutter/test/sentry_native_channel_test.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: inference_failure_on_function_invocation

@TestOn('vm')

import 'package:flutter_test/flutter_test.dart';
Expand Down
6 changes: 3 additions & 3 deletions flutter/test/sentry_navigator_observer_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import 'mocks.mocks.dart';
void main() {
late Fixture fixture;

PageRoute route(RouteSettings? settings) => PageRouteBuilder<void>(
PageRoute<dynamic> route(RouteSettings? settings) => PageRouteBuilder<void>(
pageBuilder: (_, __, ___) => Container(),
settings: settings,
);
Expand Down Expand Up @@ -92,7 +92,7 @@ void main() {
actualTransaction = scope.span as SentryTracer;
});

await Future.delayed(Duration(milliseconds: 500));
await Future<void>.delayed(Duration(milliseconds: 500));

expect(mockNativeChannel.numberOfEndNativeFramesCalls, 1);

Expand Down Expand Up @@ -569,7 +569,7 @@ void main() {
});

test('No RouteSettings', () {
PageRoute route() => PageRouteBuilder<void>(
PageRoute<dynamic> route() => PageRouteBuilder<void>(
pageBuilder: (_, __, ___) => Container(),
);

Expand Down
5 changes: 2 additions & 3 deletions logging/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
include: package:lints/recommended.yaml

analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
language:
strict-casts: true
strict-inference: true
strict-raw-types: true
errors:
# treat missing required parameters as a warning (not a hint)
Expand Down