Browse Source

refactor: enable analyzer option strict-inference

Signed-off-by: Nikolas Rimikis <leptopoda@users.noreply.github.com>
pull/809/head
Nikolas Rimikis 1 year ago
parent
commit
d6c75b4219
No known key found for this signature in database
GPG Key ID: 85ED1DE9786A4FF2
  1. 2
      packages/dynamite/dynamite/lib/src/helpers/type_result.dart
  2. 2
      packages/dynamite/dynamite_runtime/test/content_string_test.dart
  3. 2
      packages/neon/neon/lib/src/pages/home.dart
  4. 4
      packages/neon/neon/lib/src/utils/global.dart
  5. 2
      packages/neon/neon/lib/src/utils/global_popups.dart
  6. 4
      packages/neon/neon/lib/src/utils/push_utils.dart
  7. 2
      packages/neon/neon/lib/src/widgets/account_switcher_button.dart
  8. 2
      packages/neon/neon/lib/src/widgets/app_bar.dart
  9. 2
      packages/neon/neon/test/result_test.dart
  10. 2
      packages/neon/neon/test/settings_export_test.dart
  11. 2
      packages/neon/neon/test/stream_listenable_test.dart
  12. 2
      packages/neon/neon/test/timer_bloc_test.dart
  13. 2
      packages/neon/neon_files/lib/dialogs/choose_folder.dart
  14. 2
      packages/neon/neon_files/lib/pages/main.dart
  15. 2
      packages/neon/neon_files/lib/utils/task.dart
  16. 2
      packages/neon/neon_files/lib/widgets/actions.dart
  17. 2
      packages/neon/neon_files/lib/widgets/browser_view.dart
  18. 4
      packages/neon/neon_news/lib/widgets/articles_view.dart
  19. 6
      packages/neon/neon_news/lib/widgets/feeds_view.dart
  20. 2
      packages/neon/neon_news/lib/widgets/folders_view.dart
  21. 2
      packages/neon/neon_notes/lib/widgets/categories_view.dart
  22. 2
      packages/neon/neon_notes/lib/widgets/category_select.dart
  23. 2
      packages/neon/neon_notes/lib/widgets/notes_view.dart
  24. 2
      packages/neon/neon_notifications/lib/pages/main.dart
  25. 1
      packages/neon_lints/lib/src/base.yaml
  26. 1
      packages/neon_lints/lint_maker.yaml
  27. 8
      packages/nextcloud/lib/src/api/dashboard.openapi.dart
  28. 8
      packages/nextcloud/lib/src/api/provisioning_api.openapi.dart
  29. 8
      packages/nextcloud/lib/src/webdav/client.dart
  30. 2
      packages/nextcloud/test/helper.dart

2
packages/dynamite/dynamite/lib/src/helpers/type_result.dart

@ -6,7 +6,7 @@ String valueToEscapedValue(final TypeResult result, final String value) {
return "'$value'"; return "'$value'";
} }
if (result is TypeResultList) { if (result is TypeResultList) {
return 'const $value'; return 'const <${result.subType.name}>$value';
} }
if (result is TypeResultEnum) { if (result is TypeResultEnum) {
return '${result.name}.${toDartName(value)}'; return '${result.name}.${toDartName(value)}';

2
packages/dynamite/dynamite_runtime/test/content_string_test.dart

@ -1,4 +1,4 @@
// ignore_for_file: avoid_redundant_argument_values // ignore_for_file: avoid_redundant_argument_values, inference_failure_on_instance_creation
import 'dart:convert'; import 'dart:convert';

2
packages/neon/neon/lib/src/pages/home.dart

@ -99,7 +99,7 @@ class _HomePageState extends State<HomePage> {
Future<void> _showProblem(final String title) async { Future<void> _showProblem(final String title) async {
final colorScheme = Theme.of(context).colorScheme; final colorScheme = Theme.of(context).colorScheme;
await showDialog( await showDialog<void>(
context: context, context: context,
builder: (final context) => AlertDialog( builder: (final context) => AlertDialog(
title: Text(title), title: Text(title),

4
packages/neon/neon/lib/src/utils/global.dart

@ -5,6 +5,6 @@ import 'package:neon/src/models/push_notification.dart';
class Global { class Global {
const Global._(); const Global._();
static Function(String accountID)? onPushNotificationReceived; static Future<void> Function(String accountID)? onPushNotificationReceived;
static Function(PushNotification notification)? onPushNotificationClicked; static Future<void> Function(PushNotification notification)? onPushNotificationClicked;
} }

2
packages/neon/neon/lib/src/utils/global_popups.dart

@ -72,7 +72,7 @@ class GlobalPopups {
return; return;
} }
await showDialog( await showDialog<void>(
context: _context, context: _context,
builder: (final context) => AlertDialog( builder: (final context) => AlertDialog(
title: Text(AppLocalizations.of(context).nextPushSupported), title: Text(AppLocalizations.of(context).nextPushSupported),

4
packages/neon/neon/lib/src/utils/push_utils.dart

@ -89,7 +89,7 @@ class PushUtils {
await localNotificationsPlugin.cancel(_getNotificationID(instance, pushNotification)); await localNotificationsPlugin.cancel(_getNotificationID(instance, pushNotification));
} else if (pushNotification.subject.deleteAll ?? false) { } else if (pushNotification.subject.deleteAll ?? false) {
await localNotificationsPlugin.cancelAll(); await localNotificationsPlugin.cancelAll();
Global.onPushNotificationReceived?.call(instance); await Global.onPushNotificationReceived?.call(instance);
} else if (pushNotification.type == 'background') { } else if (pushNotification.type == 'background') {
debugPrint('Got unknown background notification ${json.encode(pushNotification.toJson())}'); debugPrint('Got unknown background notification ${json.encode(pushNotification.toJson())}');
} else { } else {
@ -174,7 +174,7 @@ class PushUtils {
} }
} }
Global.onPushNotificationReceived?.call(instance); await Global.onPushNotificationReceived?.call(instance);
} }
} }

2
packages/neon/neon/lib/src/widgets/account_switcher_button.dart

@ -28,7 +28,7 @@ class AccountSwitcherButton extends StatelessWidget {
title: Text(AppLocalizations.of(context).settingsAccountManage), title: Text(AppLocalizations.of(context).settingsAccountManage),
onTap: () { onTap: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
const SettingsRoute(initialCategory: SettingsCategories.accounts).push(context); const SettingsRoute(initialCategory: SettingsCategories.accounts).push<void>(context);
}, },
), ),
], ],

2
packages/neon/neon/lib/src/widgets/app_bar.dart

@ -231,7 +231,7 @@ class _NotificationIconButtonState extends State<NotificationIconButton> {
); );
await Navigator.of(context).push( await Navigator.of(context).push(
MaterialPageRoute( MaterialPageRoute<void>(
builder: (final context) => Provider<NotificationsBlocInterface>( builder: (final context) => Provider<NotificationsBlocInterface>(
create: (final context) => app.getBloc(_account), create: (final context) => app.getBloc(_account),
child: page, child: page,

2
packages/neon/neon/test/result_test.dart

@ -1,3 +1,5 @@
// ignore_for_file: inference_failure_on_instance_creation
import 'package:neon/blocs.dart'; import 'package:neon/blocs.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';

2
packages/neon/neon/test/settings_export_test.dart

@ -1,4 +1,4 @@
// ignore_for_file: avoid_implementing_value_types // ignore_for_file: avoid_implementing_value_types, inference_failure_on_collection_literal
import 'dart:convert'; import 'dart:convert';
import 'dart:typed_data'; import 'dart:typed_data';

2
packages/neon/neon/test/stream_listenable_test.dart

@ -1,4 +1,4 @@
// ignore_for_file: unreachable_from_main // ignore_for_file: unreachable_from_main, inference_failure_on_instance_creation
import 'dart:async'; import 'dart:async';

2
packages/neon/neon/test/timer_bloc_test.dart

@ -1,3 +1,5 @@
// ignore_for_file: inference_failure_on_instance_creation
import 'package:neon/blocs.dart'; import 'package:neon/blocs.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';

2
packages/neon/neon_files/lib/dialogs/choose_folder.dart

@ -49,7 +49,7 @@ class FilesChooseFolderDialog extends StatelessWidget {
child: Text(AppLocalizations.of(context).folderCreate), child: Text(AppLocalizations.of(context).folderCreate),
), ),
ElevatedButton( ElevatedButton(
onPressed: !(const ListEquality().equals(originalPath, pathSnapshot.data)) onPressed: !(const ListEquality<String>().equals(originalPath, pathSnapshot.data))
? () => Navigator.of(context).pop(pathSnapshot.data) ? () => Navigator.of(context).pop(pathSnapshot.data)
: null, : null,
child: Text(AppLocalizations.of(context).folderChoose), child: Text(AppLocalizations.of(context).folderChoose),

2
packages/neon/neon_files/lib/pages/main.dart

@ -30,7 +30,7 @@ class _FilesMainPageState extends State<FilesMainPage> {
), ),
floatingActionButton: FloatingActionButton( floatingActionButton: FloatingActionButton(
onPressed: () async { onPressed: () async {
await showDialog( await showDialog<void>(
context: context, context: context,
builder: (final context) => FilesChooseCreateDialog( builder: (final context) => FilesChooseCreateDialog(
bloc: bloc, bloc: bloc,

2
packages/neon/neon_files/lib/utils/task.dart

@ -1,3 +1,5 @@
// ignore_for_file: unnecessary_lambdas
part of '../neon_files.dart'; part of '../neon_files.dart';
sealed class FilesTask { sealed class FilesTask {

2
packages/neon/neon_files/lib/widgets/actions.dart

@ -24,7 +24,7 @@ class FileActions extends StatelessWidget {
} }
case FilesFileAction.details: case FilesFileAction.details:
await Navigator.of(context).push( await Navigator.of(context).push(
MaterialPageRoute( MaterialPageRoute<void>(
builder: (final context) => FilesDetailsPage( builder: (final context) => FilesDetailsPage(
bloc: bloc, bloc: bloc,
details: details, details: details,

2
packages/neon/neon_files/lib/widgets/browser_view.dart

@ -177,7 +177,7 @@ class _FilesBrowserViewState extends State<FilesBrowserView> {
), ),
); );
bool _pathMatchesFile(final List<String> path, final String name) => const ListEquality().equals( bool _pathMatchesFile(final List<String> path, final String name) => const ListEquality<String>().equals(
[...widget.bloc.path.value, name], [...widget.bloc.path.value, name],
path, path,
); );

4
packages/neon/neon_news/lib/widgets/articles_view.dart

@ -188,7 +188,7 @@ class _NewsArticlesViewState extends State<NewsArticlesView> {
if ((viewType == ArticleViewType.direct || article.url == null) && bodyData != null) { if ((viewType == ArticleViewType.direct || article.url == null) && bodyData != null) {
await Navigator.of(context).push( await Navigator.of(context).push(
MaterialPageRoute( MaterialPageRoute<void>(
builder: (final context) => NewsArticlePage( builder: (final context) => NewsArticlePage(
bloc: NewsArticleBloc( bloc: NewsArticleBloc(
widget.bloc, widget.bloc,
@ -205,7 +205,7 @@ class _NewsArticlesViewState extends State<NewsArticlesView> {
article.url != null && article.url != null &&
NeonPlatform.instance.canUseWebView) { NeonPlatform.instance.canUseWebView) {
await Navigator.of(context).push( await Navigator.of(context).push(
MaterialPageRoute( MaterialPageRoute<void>(
builder: (final context) => NewsArticlePage( builder: (final context) => NewsArticlePage(
bloc: NewsArticleBloc( bloc: NewsArticleBloc(
widget.bloc, widget.bloc,

6
packages/neon/neon_news/lib/widgets/feeds_view.dart

@ -64,7 +64,7 @@ class NewsFeedsView extends StatelessWidget {
if (feed.updateErrorCount > 0) ...[ if (feed.updateErrorCount > 0) ...[
IconButton( IconButton(
onPressed: () async { onPressed: () async {
await showDialog( await showDialog<void>(
context: context, context: context,
builder: (final context) => NewsFeedUpdateErrorDialog( builder: (final context) => NewsFeedUpdateErrorDialog(
feed: feed, feed: feed,
@ -105,7 +105,7 @@ class NewsFeedsView extends StatelessWidget {
onSelected: (final action) async { onSelected: (final action) async {
switch (action) { switch (action) {
case NewsFeedAction.showURL: case NewsFeedAction.showURL:
await showDialog( await showDialog<void>(
context: context, context: context,
builder: (final context) => NewsFeedShowURLDialog( builder: (final context) => NewsFeedShowURLDialog(
feed: feed, feed: feed,
@ -159,7 +159,7 @@ class NewsFeedsView extends StatelessWidget {
}, },
onTap: () async { onTap: () async {
await Navigator.of(context).push( await Navigator.of(context).push(
MaterialPageRoute( MaterialPageRoute<void>(
builder: (final context) => NewsFeedPage( builder: (final context) => NewsFeedPage(
bloc: bloc, bloc: bloc,
feed: feed, feed: feed,

2
packages/neon/neon_news/lib/widgets/folders_view.dart

@ -114,7 +114,7 @@ class NewsFoldersView extends StatelessWidget {
}, },
onTap: () async { onTap: () async {
await Navigator.of(context).push( await Navigator.of(context).push(
MaterialPageRoute( MaterialPageRoute<void>(
builder: (final context) => NewsFolderPage( builder: (final context) => NewsFolderPage(
bloc: bloc, bloc: bloc,
folder: folder, folder: folder,

2
packages/neon/neon_notes/lib/widgets/categories_view.dart

@ -52,7 +52,7 @@ class NotesCategoriesView extends StatelessWidget {
: const SizedBox.square(dimension: largeIconSize), : const SizedBox.square(dimension: largeIconSize),
onTap: () async { onTap: () async {
await Navigator.of(context).push( await Navigator.of(context).push(
MaterialPageRoute( MaterialPageRoute<void>(
builder: (final context) => NotesCategoryPage( builder: (final context) => NotesCategoryPage(
bloc: bloc, bloc: bloc,
category: category, category: category,

2
packages/neon/neon_notes/lib/widgets/category_select.dart

@ -21,7 +21,7 @@ class NotesCategorySelect extends StatelessWidget {
final List<String> categories; final List<String> categories;
final String? initialValue; final String? initialValue;
final Function(String category) onChanged; final ValueChanged<String> onChanged;
final VoidCallback onSubmitted; final VoidCallback onSubmitted;
@override @override

2
packages/neon/neon_notes/lib/widgets/notes_view.dart

@ -76,7 +76,7 @@ class NotesView extends StatelessWidget {
), ),
onTap: () async { onTap: () async {
await Navigator.of(context).push( await Navigator.of(context).push(
MaterialPageRoute( MaterialPageRoute<void>(
builder: (final context) => NotesNotePage( builder: (final context) => NotesNotePage(
bloc: NotesNoteBloc( bloc: NotesNoteBloc(
bloc, bloc,

2
packages/neon/neon_notifications/lib/pages/main.dart

@ -95,7 +95,7 @@ class _NotificationsMainPageState extends State<NotificationsMainPage> {
} else { } else {
final colorScheme = Theme.of(context).colorScheme; final colorScheme = Theme.of(context).colorScheme;
await showDialog( await showDialog<void>(
context: context, context: context,
builder: (final context) => AlertDialog( builder: (final context) => AlertDialog(
title: Text(AppLocalizations.of(context).notificationAppNotImplementedYet), title: Text(AppLocalizations.of(context).notificationAppNotImplementedYet),

1
packages/neon_lints/lib/src/base.yaml

@ -1,6 +1,7 @@
analyzer: analyzer:
language: language:
strict-casts: true strict-casts: true
strict-inference: true
strict-raw-types: true strict-raw-types: true
errors: errors:
flutter_style_todos: ignore flutter_style_todos: ignore

1
packages/neon_lints/lint_maker.yaml

@ -19,6 +19,7 @@ dart:
analyzer: analyzer:
language: language:
strict-casts: true strict-casts: true
strict-inference: true
strict-raw-types: true strict-raw-types: true
errors: errors:
flutter_style_todos: ignore flutter_style_todos: ignore

8
packages/nextcloud/lib/src/api/dashboard.openapi.dart

@ -120,7 +120,7 @@ class DashboardDashboardApiClient {
Future<DashboardDashboardApiGetWidgetItemsResponseApplicationJson> getWidgetItems({ Future<DashboardDashboardApiGetWidgetItemsResponseApplicationJson> getWidgetItems({
final ContentString<BuiltMap<String, String>>? sinceIds, final ContentString<BuiltMap<String, String>>? sinceIds,
final int limit = 7, final int limit = 7,
final List<String> widgets = const [], final List<String> widgets = const <String>[],
final String oCSAPIRequest = 'true', final String oCSAPIRequest = 'true',
}) async { }) async {
const path = '/ocs/v2.php/apps/dashboard/api/v1/widget-items'; const path = '/ocs/v2.php/apps/dashboard/api/v1/widget-items';
@ -153,7 +153,7 @@ class DashboardDashboardApiClient {
if (limit != 7) { if (limit != 7) {
queryParameters['limit'] = limit.toString(); queryParameters['limit'] = limit.toString();
} }
if (widgets != const []) { if (widgets != const <String>[]) {
queryParameters['widgets[]'] = widgets.map((final e) => e); queryParameters['widgets[]'] = widgets.map((final e) => e);
} }
headers['OCS-APIRequest'] = oCSAPIRequest; headers['OCS-APIRequest'] = oCSAPIRequest;
@ -176,7 +176,7 @@ class DashboardDashboardApiClient {
Future<DashboardDashboardApiGetWidgetItemsV2ResponseApplicationJson> getWidgetItemsV2({ Future<DashboardDashboardApiGetWidgetItemsV2ResponseApplicationJson> getWidgetItemsV2({
final ContentString<BuiltMap<String, String>>? sinceIds, final ContentString<BuiltMap<String, String>>? sinceIds,
final int limit = 7, final int limit = 7,
final List<String> widgets = const [], final List<String> widgets = const <String>[],
final String oCSAPIRequest = 'true', final String oCSAPIRequest = 'true',
}) async { }) async {
const path = '/ocs/v2.php/apps/dashboard/api/v2/widget-items'; const path = '/ocs/v2.php/apps/dashboard/api/v2/widget-items';
@ -209,7 +209,7 @@ class DashboardDashboardApiClient {
if (limit != 7) { if (limit != 7) {
queryParameters['limit'] = limit.toString(); queryParameters['limit'] = limit.toString();
} }
if (widgets != const []) { if (widgets != const <String>[]) {
queryParameters['widgets[]'] = widgets.map((final e) => e); queryParameters['widgets[]'] = widgets.map((final e) => e);
} }
headers['OCS-APIRequest'] = oCSAPIRequest; headers['OCS-APIRequest'] = oCSAPIRequest;

8
packages/nextcloud/lib/src/api/provisioning_api.openapi.dart

@ -1185,8 +1185,8 @@ class ProvisioningApiUsersClient {
final String password = '', final String password = '',
final String displayName = '', final String displayName = '',
final String email = '', final String email = '',
final List<String> groups = const [], final List<String> groups = const <String>[],
final List<String> subadmin = const [], final List<String> subadmin = const <String>[],
final String quota = '', final String quota = '',
final String language = '', final String language = '',
final String? manager, final String? manager,
@ -1221,10 +1221,10 @@ class ProvisioningApiUsersClient {
if (email != '') { if (email != '') {
queryParameters['email'] = email; queryParameters['email'] = email;
} }
if (groups != const []) { if (groups != const <String>[]) {
queryParameters['groups[]'] = groups.map((final e) => e); queryParameters['groups[]'] = groups.map((final e) => e);
} }
if (subadmin != const []) { if (subadmin != const <String>[]) {
queryParameters['subadmin[]'] = subadmin.map((final e) => e); queryParameters['subadmin[]'] = subadmin.map((final e) => e);
} }
if (quota != '') { if (quota != '') {

8
packages/nextcloud/lib/src/webdav/client.dart

@ -160,7 +160,7 @@ class WebDavClient {
final DateTime? lastModified, final DateTime? lastModified,
final DateTime? created, final DateTime? created,
final int? contentLength, final int? contentLength,
final Function(double progres)? onProgress, final void Function(double progres)? onProgress,
}) async { }) async {
var uploaded = 0; var uploaded = 0;
return _send( return _send(
@ -193,7 +193,7 @@ class WebDavClient {
final Uri path, { final Uri path, {
final DateTime? lastModified, final DateTime? lastModified,
final DateTime? created, final DateTime? created,
final Function(double progres)? onProgress, final void Function(double progres)? onProgress,
}) async => }) async =>
putStream( putStream(
file.openRead().cast<Uint8List>(), file.openRead().cast<Uint8List>(),
@ -217,12 +217,12 @@ class WebDavClient {
Future<void> getFile( Future<void> getFile(
final Uri path, final Uri path,
final File file, { final File file, {
final Function(double progress)? onProgress, final void Function(double progress)? onProgress,
}) async { }) async {
final sink = file.openWrite(); final sink = file.openWrite();
final response = await getStream(path); final response = await getStream(path);
if (response.contentLength > 0) { if (response.contentLength > 0) {
final completer = Completer(); final completer = Completer<void>();
var downloaded = 0; var downloaded = 0;
response.listen((final chunk) async { response.listen((final chunk) async {

2
packages/nextcloud/test/helper.dart

@ -1,3 +1,5 @@
// ignore_for_file: inference_failure_on_instance_creation
import 'dart:async'; import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:io'; import 'dart:io';

Loading…
Cancel
Save