Browse Source

Merge pull request #927 from nextcloud/refactor/cleanup-ignore-for-files

refactor: Cleanup ignore_for_file's
pull/938/head
Kate 1 year ago committed by GitHub
parent
commit
a898ec1a34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      packages/dynamite/dynamite_runtime/test/content_string_test.dart
  2. 4
      packages/neon/neon/test/app_implementation_test.dart
  3. 4
      packages/neon/neon/test/disposable_test.dart
  4. 9
      packages/neon/neon/test/settings_export_test.dart
  5. 12
      packages/neon/neon/test/stream_listenable_test.dart
  6. 6
      packages/neon/neon/test/timer_bloc_test.dart
  7. 12
      packages/neon/neon_files/lib/utils/task.dart
  8. 4
      packages/nextcloud/test/helper.dart

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

@ -1,4 +1,4 @@
// ignore_for_file: avoid_redundant_argument_values, inference_failure_on_instance_creation // ignore_for_file: avoid_redundant_argument_values
import 'dart:convert'; import 'dart:convert';
@ -131,7 +131,7 @@ void main() {
}); });
group('ContentString with unknown specifiedType holding list', () { group('ContentString with unknown specifiedType holding list', () {
final data = ContentString((final b) => b..content = BuiltList([1, 2, 3])); final data = ContentString((final b) => b..content = BuiltList<int>([1, 2, 3]));
final serialized = json.decode( final serialized = json.decode(
json.encode({ json.encode({
r'$': 'ContentString', r'$': 'ContentString',
@ -176,7 +176,7 @@ void main() {
}); });
group('ContentString with unknown specifiedType holding map', () { group('ContentString with unknown specifiedType holding map', () {
final data = ContentString((final b) => b..content = BuiltMap({'one': 1, 'two': 2, 'three': 3})); final data = ContentString((final b) => b..content = BuiltMap<String, int>({'one': 1, 'two': 2, 'three': 3}));
final serialized = json.decode( final serialized = json.decode(
json.encode({ json.encode({
r'$': 'ContentString', r'$': 'ContentString',

4
packages/neon/neon/test/app_implementation_test.dart

@ -1,10 +1,8 @@
// ignore_for_file: avoid_implementing_value_types
import 'package:mocktail/mocktail.dart'; import 'package:mocktail/mocktail.dart';
import 'package:neon/src/models/app_implementation.dart'; import 'package:neon/src/models/app_implementation.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
// ignore: missing_override_of_must_be_overridden // ignore: missing_override_of_must_be_overridden, avoid_implementing_value_types
class AppImplementationMock extends Mock implements AppImplementation {} class AppImplementationMock extends Mock implements AppImplementation {}
void main() { void main() {

4
packages/neon/neon/test/disposable_test.dart

@ -1,5 +1,3 @@
// ignore_for_file: cascade_invocations
import 'package:mocktail/mocktail.dart'; import 'package:mocktail/mocktail.dart';
import 'package:neon/src/models/disposable.dart'; import 'package:neon/src/models/disposable.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
@ -18,6 +16,7 @@ void main() {
disposable3, disposable3,
]; ];
// ignore: cascade_invocations
list.disposeAll(); list.disposeAll();
verify(disposable0.dispose).called(1); verify(disposable0.dispose).called(1);
@ -30,6 +29,7 @@ void main() {
'disposable3': disposable3, 'disposable3': disposable3,
}; };
// ignore: cascade_invocations
map.disposeAll(); map.disposeAll();
verify(disposable0.dispose).called(1); verify(disposable0.dispose).called(1);

9
packages/neon/neon/test/settings_export_test.dart

@ -1,5 +1,3 @@
// 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';
@ -14,13 +12,14 @@ import 'package:neon/src/utils/account_options.dart';
import 'package:rxdart/rxdart.dart'; import 'package:rxdart/rxdart.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
// ignore: missing_override_of_must_be_overridden // ignore: missing_override_of_must_be_overridden, avoid_implementing_value_types
class FakeAppImplementation extends Mock implements AppImplementation {} class FakeAppImplementation extends Mock implements AppImplementation {}
class NextcloudAppOptionsMock extends Mock implements NextcloudAppOptions {} class NextcloudAppOptionsMock extends Mock implements NextcloudAppOptions {}
class AccountsBlocMock extends Mock implements AccountsBloc {} class AccountsBlocMock extends Mock implements AccountsBloc {}
// ignore: avoid_implementing_value_types
class FakeAccount extends Mock implements Account {} class FakeAccount extends Mock implements Account {}
class AccountSpecificOptionsMock extends Mock implements AccountSpecificOptions {} class AccountSpecificOptionsMock extends Mock implements AccountSpecificOptions {}
@ -33,7 +32,7 @@ void main() {
var exporter = const AppImplementationsExporter([]); var exporter = const AppImplementationsExporter([]);
var export = exporter.export(); var export = exporter.export();
expect(Map.fromEntries([export]), {'app': {}}); expect(Map.fromEntries([export]), {'app': <String, dynamic>{}});
final fakeApp = FakeAppImplementation(); final fakeApp = FakeAppImplementation();
final fakeOptions = NextcloudAppOptionsMock(); final fakeOptions = NextcloudAppOptionsMock();
@ -66,7 +65,7 @@ void main() {
when(() => bloc.accounts).thenAnswer((final _) => BehaviorSubject.seeded([])); when(() => bloc.accounts).thenAnswer((final _) => BehaviorSubject.seeded([]));
var export = exporter.export(); var export = exporter.export();
expect(Map.fromEntries([export]), {'accounts': {}}); expect(Map.fromEntries([export]), {'accounts': <String, dynamic>{}});
final fakeAccount = FakeAccount(); final fakeAccount = FakeAccount();
final fakeOptions = AccountSpecificOptionsMock(); final fakeOptions = AccountSpecificOptionsMock();

12
packages/neon/neon/test/stream_listenable_test.dart

@ -1,5 +1,3 @@
// ignore_for_file: unreachable_from_main, inference_failure_on_instance_creation
import 'dart:async'; import 'dart:async';
import 'package:mocktail/mocktail.dart'; import 'package:mocktail/mocktail.dart';
@ -22,11 +20,11 @@ void main() {
verifyNever(callback.call); verifyNever(callback.call);
stream.value = true; stream.value = true;
await Future.delayed(const Duration(milliseconds: 100)); await Future<void>.delayed(const Duration(milliseconds: 100));
verify(callback.call).called(1); verify(callback.call).called(1);
stream.value = true; stream.value = true;
await Future.delayed(const Duration(milliseconds: 100)); await Future<void>.delayed(const Duration(milliseconds: 100));
verify(callback.call).called(1); verify(callback.call).called(1);
unawaited(stream.close()); unawaited(stream.close());
@ -45,11 +43,11 @@ void main() {
verifyNever(callback.call); verifyNever(callback.call);
stream.value = true; stream.value = true;
await Future.delayed(const Duration(milliseconds: 100)); await Future<void>.delayed(const Duration(milliseconds: 100));
verify(callback.call).called(1); verify(callback.call).called(1);
stream2.value = 3; stream2.value = 3;
await Future.delayed(const Duration(milliseconds: 100)); await Future<void>.delayed(const Duration(milliseconds: 100));
verify(callback.call).called(1); verify(callback.call).called(1);
unawaited(stream.close()); unawaited(stream.close());
@ -57,7 +55,7 @@ void main() {
}); });
test('dispose', () { test('dispose', () {
final controller = StreamController(); final controller = StreamController<void>();
final listenable = StreamListenable(controller.stream); final listenable = StreamListenable(controller.stream);

6
packages/neon/neon/test/timer_bloc_test.dart

@ -1,5 +1,3 @@
// 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';
@ -15,7 +13,7 @@ void main() {
final stopwatch = Stopwatch()..start(); final stopwatch = Stopwatch()..start();
final callback = stopwatch.stop; final callback = stopwatch.stop;
TimerBloc().registerTimer(duration, callback); TimerBloc().registerTimer(duration, callback);
await Future.delayed(duration); await Future<void>.delayed(duration);
expect(stopwatch.elapsedMilliseconds, greaterThan(duration.inMilliseconds)); expect(stopwatch.elapsedMilliseconds, greaterThan(duration.inMilliseconds));
expect(stopwatch.elapsedMilliseconds, lessThan(duration.inMilliseconds * 2)); expect(stopwatch.elapsedMilliseconds, lessThan(duration.inMilliseconds * 2));
@ -28,7 +26,7 @@ void main() {
final callback = neverCalled; final callback = neverCalled;
TimerBloc().registerTimer(duration, callback).cancel(); TimerBloc().registerTimer(duration, callback).cancel();
await Future.delayed(duration); await Future<void>.delayed(duration);
expect(TimerBloc().callbacks[duration.inSeconds], isNot(contains(callback))); expect(TimerBloc().callbacks[duration.inSeconds], isNot(contains(callback)));
}); });

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

@ -1,5 +1,3 @@
// ignore_for_file: unnecessary_lambdas
part of '../neon_files.dart'; part of '../neon_files.dart';
sealed class FilesTask { sealed class FilesTask {
@ -29,10 +27,9 @@ class FilesDownloadTask extends FilesTask {
await client.webdav.getFile( await client.webdav.getFile(
Uri(pathSegments: path), Uri(pathSegments: path),
file, file,
onProgress: (final progress) { onProgress: streamController.add,
streamController.add(progress);
},
); );
await streamController.close();
} }
} }
@ -51,9 +48,8 @@ class FilesUploadTask extends FilesTask {
stat, stat,
Uri(pathSegments: path), Uri(pathSegments: path),
lastModified: stat.modified, lastModified: stat.modified,
onProgress: (final progress) { onProgress: streamController.add,
streamController.add(progress);
},
); );
await streamController.close();
} }
} }

4
packages/nextcloud/test/helper.dart

@ -1,5 +1,3 @@
// 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';
@ -143,7 +141,7 @@ Future<TestNextcloudClient> getTestClient(
break; break;
} on DynamiteApiException catch (error) { } on DynamiteApiException catch (error) {
i++; i++;
await Future.delayed(const Duration(milliseconds: 100)); await Future<void>.delayed(const Duration(milliseconds: 100));
if (i >= 30) { if (i >= 30) {
throw TimeoutException('Failed to get the status of the Server. $error'); throw TimeoutException('Failed to get the status of the Server. $error');
} }

Loading…
Cancel
Save