Standardize lints to dart_flutter_team_lints (#198)
diff --git a/examples/autosnapshotting/analysis_options.yaml b/examples/autosnapshotting/analysis_options.yaml index e48da55..f9b3034 100644 --- a/examples/autosnapshotting/analysis_options.yaml +++ b/examples/autosnapshotting/analysis_options.yaml
@@ -1 +1 @@ -include: ../../pkgs/leak_tracker/analysis_options.yaml +include: package:flutter_lints/flutter.yaml
diff --git a/examples/autosnapshotting/integration_test/app_test.dart b/examples/autosnapshotting/integration_test/app_test.dart index 2665deb..499387f 100644 --- a/examples/autosnapshotting/integration_test/app_test.dart +++ b/examples/autosnapshotting/integration_test/app_test.dart
@@ -24,7 +24,7 @@ testWidgets('Snapshots are not taken after reaching limit', (tester) async { // Delay needed to detect memory usage is increased and take snapshot. - final delayForSnapshot = const Duration(seconds: 10); + const delayForSnapshot = Duration(seconds: 10); app.main([], snapshotDirectory: '$_testDirRoot/$pid'); await tester.pumpAndSettle(); @@ -45,7 +45,7 @@ // Take second threshold final secondThreshold = pageState.lastRss + config.autoSnapshottingConfig!.increaseMb!.mbToBytes; - int snapshotsLength = pageState.snapshots.length; + var snapshotsLength = pageState.snapshots.length; while (pageState.lastRss <= secondThreshold) { await tester.tap(theButton); await tester.pumpAndSettle();
diff --git a/examples/leak_tracking/analysis_options.yaml b/examples/leak_tracking/analysis_options.yaml index e48da55..f9b3034 100644 --- a/examples/leak_tracking/analysis_options.yaml +++ b/examples/leak_tracking/analysis_options.yaml
@@ -1 +1 @@ -include: ../../pkgs/leak_tracker/analysis_options.yaml +include: package:flutter_lints/flutter.yaml
diff --git a/examples/leak_tracking/pubspec.yaml b/examples/leak_tracking/pubspec.yaml index 706dc82..a677a31 100644 --- a/examples/leak_tracking/pubspec.yaml +++ b/examples/leak_tracking/pubspec.yaml
@@ -2,7 +2,7 @@ publish_to: none environment: - sdk: ^3.0.0 + sdk: ^3.1.0 dependencies: flutter:
diff --git a/pkgs/leak_tracker/analysis_options.yaml b/pkgs/leak_tracker/analysis_options.yaml index 50af61a..42d5822 100644 --- a/pkgs/leak_tracker/analysis_options.yaml +++ b/pkgs/leak_tracker/analysis_options.yaml
@@ -1,4 +1,4 @@ -include: package:lints/recommended.yaml +include: package:dart_flutter_team_lints/analysis_options.yaml analyzer: language: @@ -7,7 +7,4 @@ linter: rules: - - avoid_catching_errors - avoid_print - - comment_references - - only_throw_errors
diff --git a/pkgs/leak_tracker/lib/src/devtools_integration/_protocol.dart b/pkgs/leak_tracker/lib/src/devtools_integration/_protocol.dart index d70bb85..fb20481 100644 --- a/pkgs/leak_tracker/lib/src/devtools_integration/_protocol.dart +++ b/pkgs/leak_tracker/lib/src/devtools_integration/_protocol.dart
@@ -7,7 +7,8 @@ import '../shared/shared_model.dart'; import 'messages.dart'; -/// Generic parameter is not used for encoder, because the message type cannot be detected in runtime. +/// Generic parameter is not used for encoder, because +/// the message type cannot be detected in runtime. typedef AppMessageEncoder = Map<String, dynamic> Function(dynamic message); typedef AppMessageDecoder<T> = T Function(Map<String, dynamic> message); @@ -18,14 +19,15 @@ responseFromApp, } -/// Codes to identify event types in interaction between application and DevTools. +/// Codes to identify event types in interaction between +/// an application and DevTools. /// /// When application starts real tracking, it sends [started]. As soon as it /// catch new leaks, it sends [summary] information about collected leaks. /// -/// When user wants to get more about the collected leaks, they request details in -/// DevTools, devtools sends [detailsRequest] to the app, and the app responds with -/// [leakDetails]. +/// When user wants to get more info about the collected leaks, they +/// request details in DevTools, DevTools sends [detailsRequest] to the app, +/// and the app responds with [leakDetails]. @visibleForTesting enum Codes { // Events from app. @@ -102,13 +104,13 @@ _Envelope<LeakTrackingStarted>( Codes.started, Channel.eventFromApp, - (Map<String, dynamic> json) => LeakTrackingStarted.fromJson(json), + LeakTrackingStarted.fromJson, (message) => (message as LeakTrackingStarted).toJson(), ), _Envelope<LeakSummary>( Codes.summary, Channel.eventFromApp, - (Map<String, dynamic> json) => LeakSummary.fromJson(json), + LeakSummary.fromJson, (message) => (message as LeakSummary).toJson(), ), @@ -126,7 +128,7 @@ _Envelope<Leaks>( Codes.leakDetails, Channel.responseFromApp, - (Map<String, dynamic> json) => Leaks.fromJson(json), + Leaks.fromJson, (message) => (message as Leaks).toJson(), ), @@ -140,14 +142,14 @@ _Envelope<UnexpectedRequestTypeError>( Codes.unexpectedRequestTypeError, Channel.responseFromApp, - (Map<String, dynamic> json) => UnexpectedRequestTypeError.fromJson(json), + UnexpectedRequestTypeError.fromJson, (message) => (message as UnexpectedRequestTypeError).toJson(), ), _Envelope<UnexpectedError>( Codes.unexpectedError, Channel.responseFromApp, - (Map<String, dynamic> json) => UnexpectedError.fromJson(json), + UnexpectedError.fromJson, (message) => (message as UnexpectedError).toJson(), ), ];
diff --git a/pkgs/leak_tracker/lib/src/leak_tracking/_baseliner.dart b/pkgs/leak_tracker/lib/src/leak_tracking/_baseliner.dart index 5eb6f9e..b184843 100644 --- a/pkgs/leak_tracker/lib/src/leak_tracking/_baseliner.dart +++ b/pkgs/leak_tracker/lib/src/leak_tracking/_baseliner.dart
@@ -78,7 +78,8 @@ } buffer.writeln( - 'samples: ${current.samples} - ${golden.samples} = ${current.samples - golden.samples}', + 'samples: ${current.samples} - ${golden.samples} = ' + '${current.samples - golden.samples}', ); return buffer.toString(); } @@ -87,6 +88,7 @@ String format(num size) => prettyPrintBytes(size, includeUnit: true) ?? ''; final delta = current - golden; final deltaPercent = (delta / golden * 100).toStringAsFixed(2); - return '$name: ${format(current)} - ${format(golden)} = ${format(delta)} ($deltaPercent%)'; + return '$name: ${format(current)} - ${format(golden)} = ' + '${format(delta)} ($deltaPercent%)'; } }
diff --git a/pkgs/leak_tracker/lib/src/leak_tracking/_object_record_set.dart b/pkgs/leak_tracker/lib/src/leak_tracking/_object_record_set.dart index 85ae5fa..84c7691 100644 --- a/pkgs/leak_tracker/lib/src/leak_tracking/_object_record_set.dart +++ b/pkgs/leak_tracker/lib/src/leak_tracking/_object_record_set.dart
@@ -36,7 +36,7 @@ void remove(ObjectRecord record) { final list = _records[record.code]; if (list == null) return; - bool removed = false; + var removed = false; list.removeWhere((r) { if (r == record) { assert(!removed);
diff --git a/pkgs/leak_tracker/lib/src/leak_tracking/_object_records.dart b/pkgs/leak_tracker/lib/src/leak_tracking/_object_records.dart index 6828dda..a944221 100644 --- a/pkgs/leak_tracker/lib/src/leak_tracking/_object_records.dart +++ b/pkgs/leak_tracker/lib/src/leak_tracking/_object_records.dart
@@ -12,7 +12,8 @@ /// On registration, each object enters the collections [notGCed]. /// On disposal it is added to [notGCedDisposedOk]. Then, if it is overdue /// to be GCed it migrates from to [notGCedDisposedLate]. -/// Then, if the leak is collected, it migrates to [notGCedDisposedLateCollected]. +/// Then, if the leak is collected, it +/// migrates to [notGCedDisposedLateCollected]. /// /// If the object gets GCed, it is removed from all notGCed... collections, /// and, if it was GCed wrongly, added to one of gced... collections.
diff --git a/pkgs/leak_tracker/lib/src/leak_tracking/_object_tracker.dart b/pkgs/leak_tracker/lib/src/leak_tracking/_object_tracker.dart index 4083485..a0311c8 100644 --- a/pkgs/leak_tracker/lib/src/leak_tracking/_object_tracker.dart +++ b/pkgs/leak_tracker/lib/src/leak_tracking/_object_tracker.dart
@@ -103,10 +103,12 @@ /// Declares all not disposed objects as leaks, even if they are not GCed yet. /// - /// Is used to make sure all disposables are disposed by the the end of the test. + /// Is used to make sure all disposables are disposed + /// by the the end of the test. void declareAllNotDisposedAsLeaks() { throwIfDisposed(); - // We need this temporary storage to avoid error 'concurrent modification during iteration' + // We need this temporary storage to avoid error + // 'concurrent modification during iteration' // for internal iterables in `_objects.notGCed`. final notGCedAndNotDisposed = <ObjectRecord>[]; _objects.notGCed.forEach((record) { @@ -122,7 +124,8 @@ throwIfDisposed(); final record = _objects.notGCed.record(object); - // If object is not registered, this may mean that it was created when leak tracking was off. + // If object is not registered, this may mean that + // it was created when leak tracking was off. if (record == null || record.phase.ignoreLeaks) return; record.mergeContext(context); @@ -143,7 +146,8 @@ throwIfDisposed(); final record = _objects.notGCed.record(object); - // If object is not registered, this may mean that it was created when leak tracking was off. + // If object is not registered, this may mean that + // it was created when leak tracking was off. if (record == null || record.phase.ignoreLeaks) return; record.mergeContext(context); @@ -164,11 +168,10 @@ Future<void> _checkForNewNotGCedLeaks({bool summary = false}) async { _objects.assertIntegrity(); - final List<ObjectRecord>? objectsToGetPath = summary ? null : []; + final objectsToGetPath = summary ? null : <ObjectRecord>[]; final now = clock.now(); - for (ObjectRecord record - in _objects.notGCedDisposedOk.toList(growable: false)) { + for (final record in _objects.notGCedDisposedOk.toList(growable: false)) { if (record.isNotGCedLeak( _gcCounter.gcCount, now, @@ -192,7 +195,8 @@ _objects.assertIntegrity(); } - /// Runs [processor] for first items from [items], at most [limit] items will be processed. + /// Runs [processor] for first items from [items], + /// at most [limit] items will be processed. /// /// Noop if [items] is null or empty. /// Processes all items if [limit] is null.
diff --git a/pkgs/leak_tracker/lib/src/leak_tracking/helpers.dart b/pkgs/leak_tracker/lib/src/leak_tracking/helpers.dart index 36a7cb7..f05bcda 100644 --- a/pkgs/leak_tracker/lib/src/leak_tracking/helpers.dart +++ b/pkgs/leak_tracker/lib/src/leak_tracking/helpers.dart
@@ -17,8 +17,8 @@ /// Use [timeout] to limit waiting time. /// Use [fullGcCycles] to force multiple garbage collections. /// -/// The method is helpful for testing in combination with [WeakReference] to ensure -/// an object is not held by another object from garbage collection. +/// The method is helpful for testing in combination with [WeakReference] to +/// ensure an object is not held by another object from garbage collection. /// /// For code example see /// https://github.com/dart-lang/leak_tracker/blob/main/doc/TROUBLESHOOT.md @@ -26,10 +26,10 @@ Duration? timeout, int fullGcCycles = 1, }) async { - final Stopwatch? stopwatch = timeout == null ? null : (Stopwatch()..start()); - final int barrier = reachabilityBarrier; + final stopwatch = timeout == null ? null : (Stopwatch()..start()); + final barrier = reachabilityBarrier; - final List<List<int>> storage = <List<int>>[]; + final storage = <List<int>>[]; void allocateMemory() { storage.add(List.generate(30000, (n) => n));
diff --git a/pkgs/leak_tracker/lib/src/leak_tracking/leak_tracking.dart b/pkgs/leak_tracker/lib/src/leak_tracking/leak_tracking.dart index a91a3f0..29501da 100644 --- a/pkgs/leak_tracker/lib/src/leak_tracking/leak_tracking.dart +++ b/pkgs/leak_tracker/lib/src/leak_tracking/leak_tracking.dart
@@ -71,7 +71,8 @@ if (config.notifyDevTools) { // While [leakTracker] will push summary leak notifications to DevTools, - // DevTools may request leak details from the application via integration. + // DevTools may request leak details from + // the application via integration. // That's why it needs [_leakProvider]. initializeDevToolsIntegration(_leakProvider); } else { @@ -110,7 +111,8 @@ /// Dispatches object creation to the leak tracker. /// - /// Use [context] to provide additional information, that may help in leak troubleshooting. + /// Use [context] to provide additional information, + /// that may help in leak troubleshooting. /// The value must be serializable. static void dispatchObjectCreated({ required String library,
diff --git a/pkgs/leak_tracker/lib/src/leak_tracking/primitives/_print_bytes.dart b/pkgs/leak_tracker/lib/src/leak_tracking/primitives/_print_bytes.dart index 4512cdb..75d9c81 100644 --- a/pkgs/leak_tracker/lib/src/leak_tracking/primitives/_print_bytes.dart +++ b/pkgs/leak_tracker/lib/src/leak_tracking/primitives/_print_bytes.dart
@@ -16,7 +16,8 @@ } // TODO(peterdjlee): Generalize to handle different kbFractionDigits. // Ensure a small number of bytes does not print as 0 KB. - // If bytes >= maxBytes and kbFractionDigits == 1, it will start rounding to 0.1 KB. + // If bytes >= maxBytes and kbFractionDigits == 1, + // it will start rounding to 0.1 KB. if (bytes.abs() < maxBytes && kbFractionDigits == 1) { var output = bytes.toString(); if (includeUnit) {
diff --git a/pkgs/leak_tracker/lib/src/leak_tracking/primitives/_retaining_path/_connection.dart b/pkgs/leak_tracker/lib/src/leak_tracking/primitives/_retaining_path/_connection.dart index 5835750..de32ef9 100644 --- a/pkgs/leak_tracker/lib/src/leak_tracking/primitives/_retaining_path/_connection.dart +++ b/pkgs/leak_tracker/lib/src/leak_tracking/primitives/_retaining_path/_connection.dart
@@ -9,7 +9,7 @@ import 'package:vm_service/vm_service_io.dart'; Future<Uri> _serviceUri() async { - Uri? uri = (await Service.getInfo()).serverWebSocketUri; + var uri = (await Service.getInfo()).serverWebSocketUri; if (uri != null) return uri; uri = (await Service.controlWebServer(enable: true)).serverWebSocketUri;
diff --git a/pkgs/leak_tracker/lib/src/leak_tracking/primitives/_retaining_path/_retaining_path.dart b/pkgs/leak_tracker/lib/src/leak_tracking/primitives/_retaining_path/_retaining_path.dart index 45e181a..ce9effa 100644 --- a/pkgs/leak_tracker/lib/src/leak_tracking/primitives/_retaining_path/_retaining_path.dart +++ b/pkgs/leak_tracker/lib/src/leak_tracking/primitives/_retaining_path/_retaining_path.dart
@@ -9,8 +9,8 @@ /// Returns retaining path for an object, if it can be detected. /// -/// If [object] is null or object reference cannot be obtained or isolate cannot be obtained, -/// returns null. +/// If [object] is null or object reference cannot be obtained or +/// isolate cannot be obtained, returns null. Future<RetainingPath?> retainingPath( VmService service, Object? object,
diff --git a/pkgs/leak_tracker/lib/src/leak_tracking/primitives/_retaining_path/_retaining_path_isolate.dart b/pkgs/leak_tracker/lib/src/leak_tracking/primitives/_retaining_path/_retaining_path_isolate.dart index e612fd6..e352038 100644 --- a/pkgs/leak_tracker/lib/src/leak_tracking/primitives/_retaining_path/_retaining_path_isolate.dart +++ b/pkgs/leak_tracker/lib/src/leak_tracking/primitives/_retaining_path/_retaining_path_isolate.dart
@@ -10,8 +10,8 @@ /// Returns retaining path for an object, if it can be detected. /// -/// If [object] is null or object reference cannot be obtained or isolate cannot be obtained, -/// returns null. +/// If [object] is null or object reference cannot be obtained or +/// isolate cannot be obtained, returns null. Future<RetainingPath?> retainingPathImpl( VmService service, Object? object,
diff --git a/pkgs/leak_tracker/lib/src/leak_tracking/primitives/_retaining_path/_retaining_path_web.dart b/pkgs/leak_tracker/lib/src/leak_tracking/primitives/_retaining_path/_retaining_path_web.dart index 36e3d94..83b1889 100644 --- a/pkgs/leak_tracker/lib/src/leak_tracking/primitives/_retaining_path/_retaining_path_web.dart +++ b/pkgs/leak_tracker/lib/src/leak_tracking/primitives/_retaining_path/_retaining_path_web.dart
@@ -8,8 +8,8 @@ /// Returns retaining path for an object, if it can be detected. /// -/// If [object] is null or object reference cannot be obtained or isolate cannot be obtained, -/// returns null. +/// If [object] is null or object reference cannot be obtained or +/// isolate cannot be obtained, returns null. Future<RetainingPath?> retainingPathImpl( VmService service, Object? object,
diff --git a/pkgs/leak_tracker/lib/src/leak_tracking/primitives/model.dart b/pkgs/leak_tracker/lib/src/leak_tracking/primitives/model.dart index c6f713d..516b15a 100644 --- a/pkgs/leak_tracker/lib/src/leak_tracking/primitives/model.dart +++ b/pkgs/leak_tracker/lib/src/leak_tracking/primitives/model.dart
@@ -26,9 +26,11 @@ /// Creates instance of [IgnoredLeaksSet]. /// /// Use this constructor to provide both [byClass] and [ignoreAll] - /// in case when you want to preserve list of classes, while temporarily turning off - /// the entire leak tracking, so that when you turn it back on for a subset of tests - /// with `copyWith(ignoreAll: false)`, the list of classes is set to needed value. + /// in case when you want to preserve list of classes, + /// while temporarily turning off the entire leak tracking, + /// so that when you turn it back on for a subset of tests + /// with `copyWith(ignoreAll: false)`, + /// the list of classes is set to needed value. const IgnoredLeaksSet({this.byClass = const {}, this.ignoreAll = false}); const IgnoredLeaksSet.ignore() : this(ignoreAll: true, byClass: const {}); @@ -43,7 +45,8 @@ /// If number of instances is `null`, all leaks are ignored. final Map<String, int?> byClass; - /// If true, all leaks are ignored, otherwise [byClass] defines what is ignored. + /// If true, all leaks are ignored, otherwise + /// [byClass] defines what is ignored. final bool ignoreAll; /// Creates a copy of this object with the given fields replaced @@ -57,7 +60,8 @@ /// Merges two ignore lists. /// - /// In the result object the ignore limit for a class is maximum of two original ignore limits. + /// In the result object the ignore limit for a class is + /// the maximum of two original ignore limits. IgnoredLeaksSet merge(IgnoredLeaksSet? other) { if (other == null) return this; final map = {...byClass}; @@ -66,8 +70,8 @@ map[theClass] = other.byClass[theClass]; continue; } - final int? otherCount = other.byClass[theClass]; - final int? thisCount = byClass[theClass]; + final otherCount = other.byClass[theClass]; + final thisCount = byClass[theClass]; if (thisCount == null || otherCount == null) { map[theClass] = null; continue; @@ -169,9 +173,10 @@ /// Configuration for diagnostics. /// -/// Stacktrace and retaining path collection can seriously affect performance and memory footprint. -/// So, it is recommended to have them disabled for leak detection and to enable them -/// only for leak troubleshooting. +/// Stacktrace and retaining path collection can +/// seriously affect performance and memory footprint. +/// So, it is recommended to have them disabled for leak detection and +/// to enable them only for leak troubleshooting. @immutable class LeakDiagnosticConfig { const LeakDiagnosticConfig({ @@ -180,10 +185,12 @@ this.collectStackTraceOnDisposal = false, }); - /// If true, stack trace will be collected on start of tracking for all classes. + /// If true, stack trace will be collected on + /// start of tracking for all classes. final bool collectStackTraceOnStart; - /// If true, stack trace will be collected on disposal for all tracked classes. + /// If true, stack trace will be collected on + /// disposal for all tracked classes. final bool collectStackTraceOnDisposal; /// If true, retaining path will be collected for non-GCed objects. @@ -229,7 +236,8 @@ ); } -/// The default value for number of full GC cycles, enough for a non reachable object to be GCed. +/// The default value for number of full GC cycles, +/// enough for a non reachable object to be GCed. /// /// It is pessimistic assuming that user will want to /// detect leaks not more often than a second. @@ -255,7 +263,8 @@ /// The leak tracker: /// - will not auto check leaks /// - when leak checking is invoked, will not send notifications - /// - will set [disposalTime] to zero, to assume the methods `dispose` are completed + /// - will set [disposalTime] to zero, to assume + /// the methods `dispose` are completed /// at the moment of leak checking LeakTrackingConfig.passive({ int numberOfGcCycles = defaultNumberOfGcCycles,
diff --git a/pkgs/leak_tracker/lib/src/shared/_formatting.dart b/pkgs/leak_tracker/lib/src/shared/_formatting.dart index ccba8ac..dc0a012 100644 --- a/pkgs/leak_tracker/lib/src/shared/_formatting.dart +++ b/pkgs/leak_tracker/lib/src/shared/_formatting.dart
@@ -43,7 +43,7 @@ } String retainingPathToString(RetainingPath retainingPath) { - final StringBuffer buffer = StringBuffer(); + final buffer = StringBuffer(); buffer.writeln( 'References that retain the object from garbage collection.', ); @@ -78,7 +78,8 @@ const RetainingObjectProperty(this.paths); - /// Itemizes possible paths in [RetainingObject.toJson] to get the value of a property. + /// Itemizes possible paths in [RetainingObject.toJson] to + /// get the value of a property. final List<List<String>> paths; }
diff --git a/pkgs/leak_tracker/lib/src/shared/_util.dart b/pkgs/leak_tracker/lib/src/shared/_util.dart index 16aa67f..85b191a 100644 --- a/pkgs/leak_tracker/lib/src/shared/_util.dart +++ b/pkgs/leak_tracker/lib/src/shared/_util.dart
@@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -/// This function is better than `as`, because `as` does not provide callstack on failure. +/// This function is better than `as`, +/// because `as` does not provide callstack on failure. T cast<T>(Object? value) { if (value is T) return value; throw ArgumentError( @@ -11,7 +12,8 @@ } extension IterableExtensions<T> on Iterable<T> { - /// Returns the item or null, assuming that the length of the iterable is 0 or 1. + /// Returns the item or null, assuming that + /// the length of the iterable is 0 or 1. // The name is consistent with other method names on iterables like // `firstOrNull, lastOrNull, and singleOrNull`. T? get onlyOrNull {
diff --git a/pkgs/leak_tracker/lib/src/shared/shared_model.dart b/pkgs/leak_tracker/lib/src/shared/shared_model.dart index 8a0f9fb..675eeed 100644 --- a/pkgs/leak_tracker/lib/src/shared/shared_model.dart +++ b/pkgs/leak_tracker/lib/src/shared/shared_model.dart
@@ -96,7 +96,7 @@ LeakType.byName(key), (value as List) .cast<Map<String, dynamic>>() - .map((e) => LeakReport.fromJson(e)) + .map(LeakReport.fromJson) .toList(growable: false), ), ),
diff --git a/pkgs/leak_tracker/pubspec.yaml b/pkgs/leak_tracker/pubspec.yaml index feb2d8b..d276974 100644 --- a/pkgs/leak_tracker/pubspec.yaml +++ b/pkgs/leak_tracker/pubspec.yaml
@@ -17,6 +17,6 @@ vm_service: '>=11.10.0 <15.0.0' dev_dependencies: + dart_flutter_team_lints: ^2.1.0 layerlens: ^1.0.0 - lints: ^3.0.0 test: ^1.16.0
diff --git a/pkgs/leak_tracker/test/test_infra/utils.dart b/pkgs/leak_tracker/test/test_infra/utils.dart index 1105af0..e4ba34a 100644 --- a/pkgs/leak_tracker/test/test_infra/utils.dart +++ b/pkgs/leak_tracker/test/test_infra/utils.dart
@@ -13,11 +13,9 @@ final completer = Completer<String>(); final content = StringBuffer(); response.transform(utf8.decoder).listen( - (data) { - content.write(data); - }, - onDone: () => completer.complete(content.toString()), - ); + content.write, + onDone: () => completer.complete(content.toString()), + ); await completer.future; return content.toString(); }
diff --git a/pkgs/leak_tracker/test/tests/devtools_integration/_envelopes_test.dart b/pkgs/leak_tracker/test/tests/devtools_integration/_envelopes_test.dart index 8a20443..734f34f 100644 --- a/pkgs/leak_tracker/test/tests/devtools_integration/_envelopes_test.dart +++ b/pkgs/leak_tracker/test/tests/devtools_integration/_envelopes_test.dart
@@ -8,9 +8,7 @@ import '../../test_infra/data/messages.dart'; void main() { - setUpAll(() { - verifyTestsCoverAllEnvelopes(); - }); + setUpAll(verifyTestsCoverAllEnvelopes); test('each code matches exactly one envelope', () { final codesInEnvelopes = Set.of(envelopes.map((e) => e.code));
diff --git a/pkgs/leak_tracker/test/tests/devtools_integration/delivery_test.dart b/pkgs/leak_tracker/test/tests/devtools_integration/delivery_test.dart index 0a5cd04..4c132c1 100644 --- a/pkgs/leak_tracker/test/tests/devtools_integration/delivery_test.dart +++ b/pkgs/leak_tracker/test/tests/devtools_integration/delivery_test.dart
@@ -16,9 +16,7 @@ .toList(), }; - setUpAll(() { - verifyTestsCoverAllEnvelopes(); - }); + setUpAll(verifyTestsCoverAllEnvelopes); for (final message in messagesByChannel[Channel.eventFromApp]!) { test('$EventFromApp serializes ${message.runtimeType}', () {
diff --git a/pkgs/leak_tracker/test/tests/leak_tracking/_object_record_set_test.dart b/pkgs/leak_tracker/test/tests/leak_tracking/_object_record_set_test.dart index e74f55f..18a96bc 100644 --- a/pkgs/leak_tracker/test/tests/leak_tracking/_object_record_set_test.dart +++ b/pkgs/leak_tracker/test/tests/leak_tracking/_object_record_set_test.dart
@@ -54,7 +54,7 @@ expect(theSet.putIfAbsent(item, {}, _phase, ''), record); expect(theSet.length, length + 1); - int count = 0; + var count = 0; theSet.forEach((record) => count++); expect(count, theSet.length); @@ -73,7 +73,7 @@ expect(theSet.contains(record), false); expect(theSet.contains(_record), false); - int count = 0; + var count = 0; theSet.forEach((record) => count++); expect(count, theSet.length);
diff --git a/pkgs/leak_tracker/test/tests/leak_tracking/_object_tracker_test.dart b/pkgs/leak_tracker/test/tests/leak_tracking/_object_tracker_test.dart index f4da0e2..41e1ca0 100644 --- a/pkgs/leak_tracker/test/tests/leak_tracking/_object_tracker_test.dart +++ b/pkgs/leak_tracker/test/tests/leak_tracking/_object_tracker_test.dart
@@ -20,7 +20,7 @@ group('processIfNeeded', () { for (var items in [null, <int>[]]) { test('is noop for empty list, $items', () async { - int processorCalls = 0; + var processorCalls = 0; await ObjectTracker.processIfNeeded<int>( items: items, @@ -38,7 +38,7 @@ test('processes all for no limit or large limit, $limit', () async { final itemsToProcess = [1, 2, 3]; - int processorCalls = 0; + var processorCalls = 0; late final List<int> processedItems; await ObjectTracker.processIfNeeded<int>( @@ -58,7 +58,7 @@ test('cuts for limit', () async { final itemsToProcess = [1, 2, 3]; - int processorCalls = 0; + var processorCalls = 0; late final List<int> processedItems; await ObjectTracker.processIfNeeded<int>( @@ -189,9 +189,7 @@ gcCounter.gcCount = gcCounter.gcCount + defaultNumberOfGcCycles * 1000; // Verify no leaks. - withClock(Clock.fixed(time), () { - verifyNoLeaks(); - }); + withClock(Clock.fixed(time), verifyNoLeaks); }); test('tracks ${LeakType.notDisposed}.', () async { @@ -521,8 +519,8 @@ false, ]) { test( - 'when objects are tracked with different settings, disposed=$disposed, gced=$gced.', - () async { + 'when objects are tracked with different settings, ' + 'disposed=$disposed, gced=$gced.', () async { var time = DateTime(2000); // Start tracking.
diff --git a/pkgs/leak_tracker/test/tests/leak_tracking/platform_test.dart b/pkgs/leak_tracker/test/tests/leak_tracking/platform_test.dart index 3bed8ef..676b2e2 100644 --- a/pkgs/leak_tracker/test/tests/leak_tracking/platform_test.dart +++ b/pkgs/leak_tracker/test/tests/leak_tracking/platform_test.dart
@@ -34,7 +34,7 @@ test('Non-referenced object is finalized and gced after barrier increase.', () async { - bool finalized = false; + var finalized = false; final finalizer = Finalizer<Object>((token) => finalized = true); final ref = await _createTrackedObject(finalizer); final barrier = reachabilityBarrier;
diff --git a/pkgs/leak_tracker_flutter_testing/analysis_options.yaml b/pkgs/leak_tracker_flutter_testing/analysis_options.yaml index 50af61a..42d5822 100644 --- a/pkgs/leak_tracker_flutter_testing/analysis_options.yaml +++ b/pkgs/leak_tracker_flutter_testing/analysis_options.yaml
@@ -1,4 +1,4 @@ -include: package:lints/recommended.yaml +include: package:dart_flutter_team_lints/analysis_options.yaml analyzer: language: @@ -7,7 +7,4 @@ linter: rules: - - avoid_catching_errors - avoid_print - - comment_references - - only_throw_errors
diff --git a/pkgs/leak_tracker_flutter_testing/lib/leak_tracker_flutter_testing.dart b/pkgs/leak_tracker_flutter_testing/lib/leak_tracker_flutter_testing.dart index 1b565d2..3b36cb3 100644 --- a/pkgs/leak_tracker_flutter_testing/lib/leak_tracker_flutter_testing.dart +++ b/pkgs/leak_tracker_flutter_testing/lib/leak_tracker_flutter_testing.dart
@@ -2,10 +2,11 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +export 'package:leak_tracker/leak_tracker.dart' + show IgnoredLeaks, LeakReport, LeakTracking, LeakType, Leaks; +export 'package:leak_tracker_testing/leak_tracker_testing.dart' + show LeakTesting, isLeakFree; + export 'src/matchers.dart'; export 'src/model.dart'; export 'src/testing.dart'; -export 'package:leak_tracker/leak_tracker.dart' - show Leaks, LeakTracking, IgnoredLeaks, LeakType, LeakReport; -export 'package:leak_tracker_testing/leak_tracker_testing.dart' - show isLeakFree, LeakTesting;
diff --git a/pkgs/leak_tracker_flutter_testing/lib/src/matchers.dart b/pkgs/leak_tracker_flutter_testing/lib/src/matchers.dart index 949cf28..455d486 100644 --- a/pkgs/leak_tracker_flutter_testing/lib/src/matchers.dart +++ b/pkgs/leak_tracker_flutter_testing/lib/src/matchers.dart
@@ -7,7 +7,8 @@ import 'package:flutter/foundation.dart'; import 'package:matcher/matcher.dart'; -/// Invokes [callback] and collects events dispatched to [MemoryAllocations.instance] for [type]. +/// Invokes [callback] and collects +/// events dispatched to [MemoryAllocations.instance] for [type]. Future<List<ObjectEvent>> memoryEvents( FutureOr<void> Function() callback, Type type, @@ -27,7 +28,8 @@ return events; } -/// Checks if Iterable<ObjectEvent> contains two events, first `ObjectCreated` and then `ObjectDisposed`. +/// Checks if Iterable<ObjectEvent> contains two events, +/// first `ObjectCreated` and then `ObjectDisposed`. Matcher areCreateAndDispose = const _AreCreateAndDispose(); class _AreCreateAndDispose extends Matcher { @@ -48,8 +50,8 @@ return true; } - matchState[_key] = - 'The events are expected to be first $ObjectCreated and then $ObjectDisposed.\n' + matchState[_key] = 'The events are expected to be first ' + '$ObjectCreated and then $ObjectDisposed.\n' 'Instead, they are ${item.length} events:\n$item.'; return false;
diff --git a/pkgs/leak_tracker_flutter_testing/lib/src/model.dart b/pkgs/leak_tracker_flutter_testing/lib/src/model.dart index 5d3a603..ee69cdd 100644 --- a/pkgs/leak_tracker_flutter_testing/lib/src/model.dart +++ b/pkgs/leak_tracker_flutter_testing/lib/src/model.dart
@@ -100,7 +100,8 @@ /// Classes that are allowed to be garbage collected without being disposed. /// /// Maps name of the class, as returned by `object.runtimeType.toString()`, - /// to the number of instances of the class that are allowed to be not disposed. + /// to the number of instances of the class that + /// are allowed to be not disposed. /// /// If number of instances is `null`, any number of instances is allowed. final Map<String, int?> notDisposedAllowList;
diff --git a/pkgs/leak_tracker_flutter_testing/lib/src/testing.dart b/pkgs/leak_tracker_flutter_testing/lib/src/testing.dart index 7d661fd..c3e4fc0 100644 --- a/pkgs/leak_tracker_flutter_testing/lib/src/testing.dart +++ b/pkgs/leak_tracker_flutter_testing/lib/src/testing.dart
@@ -25,7 +25,7 @@ _maybeStartLeakTracking(); - final PhaseSettings phase = PhaseSettings( + final phase = PhaseSettings( name: testDescription, leakDiagnosticConfig: leakTesting.leakDiagnosticConfig, ignoredLeaks: leakTesting.ignoredLeaks, @@ -36,7 +36,8 @@ LeakTracking.phase = phase; } -/// If leak tracking is enabled, stops it and declares notDisposed objects as leaks. +/// If leak tracking is enabled, stops it and +/// declares notDisposed objects as leaks. void maybeTearDownLeakTrackingForTest() { if (!LeakTracking.isStarted || LeakTracking.phase.ignoreLeaks) return; LeakTracking.phase = const PhaseSettings.ignored(); @@ -55,7 +56,7 @@ MemoryAllocations.instance.removeListener(_dispatchFlutterEventToLeakTracker); await forceGC(fullGcCycles: defaultNumberOfGcCycles); LeakTracking.declareNotDisposedObjectsAsLeaks(); - final Leaks leaks = await LeakTracking.collectLeaks(); + final leaks = await LeakTracking.collectLeaks(); LeakTracking.stop(); LeakTesting.collectedLeaksReporter(leaks); @@ -67,9 +68,11 @@ bool _notSupportedWarningPrinted = false; -/// Checks if platform supported and, if no, prints warning if the warning is needed. +/// Checks if platform supported and, if no, +/// prints warning if the warning is needed. /// -/// Warning is printed one time if `LeakTracking.warnForNotSupportedPlatforms` is true. +/// Warning is printed one time if +/// `LeakTracking.warnForNotSupportedPlatforms` is `true`. bool _checkPlatformAndMayBePrintWarning( {required String platformName, required bool isBrowser}) { final isSupported = !isBrowser; @@ -84,7 +87,8 @@ _notSupportedWarningPrinted = true; debugPrint( "Leak tracking is not supported on the platform '$platformName'.\n" - 'To turn off this message, set `LeakTracking.warnForNotSupportedPlatforms` to false.', + 'To turn off this message, set ' + '`LeakTracking.warnForNotSupportedPlatforms` to false.', ); return false;
diff --git a/pkgs/leak_tracker_flutter_testing/pubspec.yaml b/pkgs/leak_tracker_flutter_testing/pubspec.yaml index 2fe47f1..27a1b53 100644 --- a/pkgs/leak_tracker_flutter_testing/pubspec.yaml +++ b/pkgs/leak_tracker_flutter_testing/pubspec.yaml
@@ -15,5 +15,5 @@ meta: ^1.8.0 dev_dependencies: - lints: ^3.0.0 + dart_flutter_team_lints: ^2.1.0 test: ^1.25.0
diff --git a/pkgs/leak_tracker_flutter_testing/test/tests/_dispatcher_test.dart b/pkgs/leak_tracker_flutter_testing/test/tests/_dispatcher_test.dart index 98b9099..55fd45a 100644 --- a/pkgs/leak_tracker_flutter_testing/test/tests/_dispatcher_test.dart +++ b/pkgs/leak_tracker_flutter_testing/test/tests/_dispatcher_test.dart
@@ -5,8 +5,8 @@ import 'dart:ui'; import 'package:flutter/foundation.dart'; -import 'package:test/test.dart'; import 'package:leak_tracker/src/leak_tracking/primitives/_dispatcher.dart'; +import 'package:test/test.dart'; import '../test_infra/event_tracker.dart'; @@ -45,9 +45,9 @@ } Picture _createPicture() { - final PictureRecorder recorder = PictureRecorder(); - final Canvas canvas = Canvas(recorder); - const Rect rect = Rect.fromLTWH(0.0, 0.0, 100.0, 100.0); + final recorder = PictureRecorder(); + final canvas = Canvas(recorder); + const rect = Rect.fromLTWH(0.0, 0.0, 100.0, 100.0); canvas.clipRect(rect); return recorder.endRecording(); }
diff --git a/pkgs/leak_tracker_flutter_testing/test/tests/_formatting_test.dart b/pkgs/leak_tracker_flutter_testing/test/tests/_formatting_test.dart index f4a4b37..3294322 100644 --- a/pkgs/leak_tracker_flutter_testing/test/tests/_formatting_test.dart +++ b/pkgs/leak_tracker_flutter_testing/test/tests/_formatting_test.dart
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'package:test/test.dart'; import 'package:leak_tracker/src/shared/_formatting.dart'; +import 'package:test/test.dart'; const _jsonEmpty = <String, dynamic>{};
diff --git a/pkgs/leak_tracker_flutter_testing/test/tests/end_to_end/_retaining_path_test.dart b/pkgs/leak_tracker_flutter_testing/test/tests/end_to_end/_retaining_path_test.dart index b066983..e7761eb 100644 --- a/pkgs/leak_tracker_flutter_testing/test/tests/end_to_end/_retaining_path_test.dart +++ b/pkgs/leak_tracker_flutter_testing/test/tests/end_to_end/_retaining_path_test.dart
@@ -2,9 +2,9 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import 'package:test/test.dart'; import 'package:leak_tracker/src/leak_tracking/primitives/_retaining_path/_connection.dart'; import 'package:leak_tracker/src/leak_tracking/primitives/_retaining_path/_retaining_path.dart'; +import 'package:test/test.dart'; // We duplicate testing for retaining path here, // because there were cases when the tests were passing for dart,
diff --git a/pkgs/leak_tracker_flutter_testing/test/tests/leak_tracking_for_tests_test.dart b/pkgs/leak_tracker_flutter_testing/test/tests/leak_tracking_for_tests_test.dart index 932a0bf..fb0e7af 100644 --- a/pkgs/leak_tracker_flutter_testing/test/tests/leak_tracking_for_tests_test.dart +++ b/pkgs/leak_tracker_flutter_testing/test/tests/leak_tracking_for_tests_test.dart
@@ -2,9 +2,9 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import 'package:test/test.dart'; import 'package:leak_tracker/leak_tracker.dart'; import 'package:leak_tracker_testing/leak_tracker_testing.dart'; +import 'package:test/test.dart'; class _Classes { static const anyLeak1 = 'anyLeak1'; @@ -35,7 +35,8 @@ all.where((c) => !classes.contains(c)).toList(); } -/// Returns true, if the provided [classes] are skipped and all other classes from [_Classes] are tracked. +/// Returns true, if the provided [classes] are skipped and +/// all other classes from [_Classes] are tracked. bool _areOnlySkipped( List<String> classes, { LeakType? leakType,
diff --git a/pkgs/leak_tracker_flutter_testing/test/tests/matchers_test.dart b/pkgs/leak_tracker_flutter_testing/test/tests/matchers_test.dart index f421bf0..12dd59c 100644 --- a/pkgs/leak_tracker_flutter_testing/test/tests/matchers_test.dart +++ b/pkgs/leak_tracker_flutter_testing/test/tests/matchers_test.dart
@@ -3,8 +3,8 @@ // BSD-style license that can be found in the LICENSE file. import 'package:flutter/foundation.dart'; -import 'package:test/test.dart'; import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart'; +import 'package:test/test.dart'; class _TrackedClass { _TrackedClass() {
diff --git a/pkgs/leak_tracker_flutter_testing/test/tests/testing_test.dart b/pkgs/leak_tracker_flutter_testing/test/tests/testing_test.dart index 6cfd6b5..4997d18 100644 --- a/pkgs/leak_tracker_flutter_testing/test/tests/testing_test.dart +++ b/pkgs/leak_tracker_flutter_testing/test/tests/testing_test.dart
@@ -2,8 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import 'package:test/test.dart'; import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart'; +import 'package:test/test.dart'; final LeakTesting settings = LeakTesting.settings.withIgnored(allNotDisposed: true, allNotGCed: true); @@ -14,9 +14,7 @@ LeakTesting.settings = LeakTesting.settings.withTrackedAll(); }); - tearDown(() { - LeakTracking.stop(); - }); + tearDown(LeakTracking.stop); test('If settings is null, respects globals', () { maybeSetupLeakTrackingForTest(null, 'myTest1'); @@ -47,11 +45,9 @@ maybeSetupLeakTrackingForTest(null, 'myTest1'); }); - tearDown(() { - LeakTracking.stop(); - }); + tearDown(LeakTracking.stop); - test('Pauses leak tracking and can be invoiked twice', () { + test('Pauses leak tracking and can be invoked twice', () { maybeTearDownLeakTrackingForTest(); expect(LeakTracking.phase.name, null); expect(LeakTracking.isStarted, true); @@ -71,9 +67,7 @@ maybeTearDownLeakTrackingForTest(); }); - tearDown(() { - LeakTracking.stop(); - }); + tearDown(LeakTracking.stop); test('Stops leak tracking', () async { await maybeTearDownLeakTrackingForAll();
diff --git a/pkgs/leak_tracker_testing/analysis_options.yaml b/pkgs/leak_tracker_testing/analysis_options.yaml index 50af61a..42d5822 100644 --- a/pkgs/leak_tracker_testing/analysis_options.yaml +++ b/pkgs/leak_tracker_testing/analysis_options.yaml
@@ -1,4 +1,4 @@ -include: package:lints/recommended.yaml +include: package:dart_flutter_team_lints/analysis_options.yaml analyzer: language: @@ -7,7 +7,4 @@ linter: rules: - - avoid_catching_errors - avoid_print - - comment_references - - only_throw_errors
diff --git a/pkgs/leak_tracker_testing/lib/leak_tracker_testing.dart b/pkgs/leak_tracker_testing/lib/leak_tracker_testing.dart index 77e6955..f9bbec0 100644 --- a/pkgs/leak_tracker_testing/lib/leak_tracker_testing.dart +++ b/pkgs/leak_tracker_testing/lib/leak_tracker_testing.dart
@@ -2,5 +2,5 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -export 'src/matchers.dart'; export 'src/leak_testing.dart'; +export 'src/matchers.dart';
diff --git a/pkgs/leak_tracker_testing/lib/src/leak_testing.dart b/pkgs/leak_tracker_testing/lib/src/leak_testing.dart index ee29348..c46d3ed 100644 --- a/pkgs/leak_tracker_testing/lib/src/leak_testing.dart +++ b/pkgs/leak_tracker_testing/lib/src/leak_testing.dart
@@ -15,8 +15,8 @@ /// Set it for package or folder in flutter_test_config.dart and for /// a test file in `setUpAll`. /// -/// If you update the settings for a group, remember the original value to a local variable -/// and restore it in `tearDownAll` for the group. +/// If you update the settings for a group, remember the original value to a +/// local variable and restore it in `tearDownAll` for the group. /// /// Use methods that return adjusted [LeakTesting.settings] /// to customize default for an individual test: @@ -87,7 +87,8 @@ ); } - /// Creates copy of [settings], that collects retaining path for not GCed objects. + /// Creates copy of [settings], that + /// collects the retaining path for not GCed objects. @useResult LeakTesting withRetainingPath() { return copyWith( @@ -99,7 +100,8 @@ /// Returns copy of [settings] with extended ignore lists. /// - /// In the result the ignored limit for a class is maximum of two original ignored limits. + /// In the result the ignored limit for a class is the + /// maximum of two original ignored limits. /// Items in [classes] will be added to all ignore lists. @useResult LeakTesting withIgnored({
diff --git a/pkgs/leak_tracker_testing/lib/src/matchers.dart b/pkgs/leak_tracker_testing/lib/src/matchers.dart index b69b0cf..1f09028 100644 --- a/pkgs/leak_tracker_testing/lib/src/matchers.dart +++ b/pkgs/leak_tracker_testing/lib/src/matchers.dart
@@ -25,7 +25,8 @@ if (item is! Leaks) { return mismatchDescription ..add( - 'The matcher applies to $Leaks and cannot be applied to ${item.runtimeType}', + 'The matcher applies to $Leaks and cannot be ' + 'applied to ${item.runtimeType}', ); }
diff --git a/pkgs/leak_tracker_testing/pubspec.yaml b/pkgs/leak_tracker_testing/pubspec.yaml index a2df827..65e541f 100644 --- a/pkgs/leak_tracker_testing/pubspec.yaml +++ b/pkgs/leak_tracker_testing/pubspec.yaml
@@ -15,6 +15,6 @@ meta: ^1.11.0 dev_dependencies: + dart_flutter_team_lints: ^2.1.0 layerlens: ^1.0.0 - lints: ^3.0.0 test: ^1.16.0
diff --git a/pkgs/leak_tracker_testing/test/end_to_end_test.dart b/pkgs/leak_tracker_testing/test/end_to_end_test.dart index bdfb490..b5723e7 100644 --- a/pkgs/leak_tracker_testing/test/end_to_end_test.dart +++ b/pkgs/leak_tracker_testing/test/end_to_end_test.dart
@@ -9,7 +9,7 @@ import '../../leak_tracker/test/test_infra/data/dart_classes.dart'; void main() { - tearDown(() => LeakTracking.stop()); + tearDown(LeakTracking.stop); for (var numberOfGcCycles in [1, defaultNumberOfGcCycles]) { test('Passive leak tracking detects leaks, $numberOfGcCycles.', () async { @@ -205,8 +205,8 @@ expect( RegExp('^').allMatches(stringBetweenItems).length, 1, - reason: - 'There should be only one line break between items in retaining path.', + reason: 'There should be only one line break between ' + 'items in retaining path.', ); previousIndex = index; }
diff --git a/pkgs/memory_usage/pubspec.yaml b/pkgs/memory_usage/pubspec.yaml index c70965a..e660ec4 100644 --- a/pkgs/memory_usage/pubspec.yaml +++ b/pkgs/memory_usage/pubspec.yaml
@@ -10,6 +10,6 @@ path: ^1.8.3 dev_dependencies: - dart_flutter_team_lints: ^2.0.0 + dart_flutter_team_lints: ^2.1.0 layerlens: ^1.0.0 test: ^1.16.0