From 9bb20f4eac1d7f6979e602674ed1390b50a1e5c6 Mon Sep 17 00:00:00 2001 From: Bartek Pacia Date: Thu, 23 Nov 2023 10:21:00 +0100 Subject: [PATCH 1/6] set up `custom_lint` in all packages --- packages/adb/analysis_options.yaml | 4 ++++ packages/adb/pubspec.yaml | 1 + packages/patrol/analysis_options.yaml | 2 ++ .../patrol/example/integration_test/analysis_options.yaml | 6 ------ packages/patrol/pubspec.yaml | 1 + packages/patrol_cli/analysis_options.yaml | 4 ++++ packages/patrol_cli/pubspec.yaml | 1 + packages/patrol_devtools_extension/analysis_options.yaml | 2 ++ packages/patrol_devtools_extension/pubspec.yaml | 1 + packages/patrol_finders/analysis_options.yaml | 4 ++++ packages/patrol_gen/analysis_options.yaml | 8 +++----- packages/patrol_gen/pubspec.yaml | 3 ++- 12 files changed, 25 insertions(+), 12 deletions(-) delete mode 100644 packages/patrol/example/integration_test/analysis_options.yaml diff --git a/packages/adb/analysis_options.yaml b/packages/adb/analysis_options.yaml index 31551b63c..9aa974b41 100644 --- a/packages/adb/analysis_options.yaml +++ b/packages/adb/analysis_options.yaml @@ -1 +1,5 @@ include: package:leancode_lint/analysis_options_package.yaml + +analyzer: + plugins: + - custom_lint diff --git a/packages/adb/pubspec.yaml b/packages/adb/pubspec.yaml index f55fc0621..1a5efc540 100644 --- a/packages/adb/pubspec.yaml +++ b/packages/adb/pubspec.yaml @@ -8,6 +8,7 @@ environment: sdk: '>=3.2.0 <4.0.0' dev_dependencies: + custom_lint: ^0.5.7 leancode_lint: ^7.0.0+1 mocktail: ^1.0.1 test: ^1.24.9 diff --git a/packages/patrol/analysis_options.yaml b/packages/patrol/analysis_options.yaml index 36c9c08a3..938b325cd 100644 --- a/packages/patrol/analysis_options.yaml +++ b/packages/patrol/analysis_options.yaml @@ -1,5 +1,7 @@ include: package:leancode_lint/analysis_options_package.yaml analyzer: + plugins: + - custom_lint exclude: - lib/**/*.g.dart diff --git a/packages/patrol/example/integration_test/analysis_options.yaml b/packages/patrol/example/integration_test/analysis_options.yaml deleted file mode 100644 index 98093f93d..000000000 --- a/packages/patrol/example/integration_test/analysis_options.yaml +++ /dev/null @@ -1,6 +0,0 @@ -include: package:leancode_lint/analysis_options.yaml - -linter: - rules: - prefer_const_constructors: false - avoid_print: false diff --git a/packages/patrol/pubspec.yaml b/packages/patrol/pubspec.yaml index 6581c5d41..a60ccb653 100644 --- a/packages/patrol/pubspec.yaml +++ b/packages/patrol/pubspec.yaml @@ -31,6 +31,7 @@ dependencies: dev_dependencies: build_runner: ^2.4.6 + custom_lint: ^0.5.7 json_serializable: ^6.7.1 leancode_lint: ^7.0.0+1 diff --git a/packages/patrol_cli/analysis_options.yaml b/packages/patrol_cli/analysis_options.yaml index 4af9cbc42..5f56aca49 100644 --- a/packages/patrol_cli/analysis_options.yaml +++ b/packages/patrol_cli/analysis_options.yaml @@ -1 +1,5 @@ include: package:leancode_lint/analysis_options.yaml + +analyzer: + plugins: + - custom_lint diff --git a/packages/patrol_cli/pubspec.yaml b/packages/patrol_cli/pubspec.yaml index 902d17ee4..d753f750d 100644 --- a/packages/patrol_cli/pubspec.yaml +++ b/packages/patrol_cli/pubspec.yaml @@ -36,6 +36,7 @@ dependencies: yaml: ^3.1.2 dev_dependencies: build_runner: ^2.4.6 + custom_lint: ^0.5.7 fake_async: ^1.3.1 leancode_lint: ^7.0.0+1 mocktail: ^1.0.1 diff --git a/packages/patrol_devtools_extension/analysis_options.yaml b/packages/patrol_devtools_extension/analysis_options.yaml index ee7809aa4..032ea249e 100644 --- a/packages/patrol_devtools_extension/analysis_options.yaml +++ b/packages/patrol_devtools_extension/analysis_options.yaml @@ -1,5 +1,7 @@ include: package:leancode_lint/analysis_options.yaml analyzer: + plugins: + - custom_lint exclude: - lib/**/*.g.dart diff --git a/packages/patrol_devtools_extension/pubspec.yaml b/packages/patrol_devtools_extension/pubspec.yaml index 8c3af6be4..6f89b2d46 100644 --- a/packages/patrol_devtools_extension/pubspec.yaml +++ b/packages/patrol_devtools_extension/pubspec.yaml @@ -21,6 +21,7 @@ dependencies: vm_service: ^11.0.0 dev_dependencies: + custom_lint: ^0.5.7 flutter_test: sdk: flutter leancode_lint: ^7.0.0+1 diff --git a/packages/patrol_finders/analysis_options.yaml b/packages/patrol_finders/analysis_options.yaml index 31551b63c..9aa974b41 100644 --- a/packages/patrol_finders/analysis_options.yaml +++ b/packages/patrol_finders/analysis_options.yaml @@ -1 +1,5 @@ include: package:leancode_lint/analysis_options_package.yaml + +analyzer: + plugins: + - custom_lint diff --git a/packages/patrol_gen/analysis_options.yaml b/packages/patrol_gen/analysis_options.yaml index 2bdc49a2f..032ea249e 100644 --- a/packages/patrol_gen/analysis_options.yaml +++ b/packages/patrol_gen/analysis_options.yaml @@ -1,9 +1,7 @@ -include: package:leancode_lint/analysis_options_package.yaml - -linter: - rules: - public_member_api_docs: false +include: package:leancode_lint/analysis_options.yaml analyzer: + plugins: + - custom_lint exclude: - lib/**/*.g.dart diff --git a/packages/patrol_gen/pubspec.yaml b/packages/patrol_gen/pubspec.yaml index ba2680496..f1a29b7b8 100644 --- a/packages/patrol_gen/pubspec.yaml +++ b/packages/patrol_gen/pubspec.yaml @@ -14,6 +14,7 @@ dependencies: dart_style: ^2.3.3 meta: ^1.10.0 path: ^1.8.3 - + dev_dependencies: + custom_lint: ^0.5.7 leancode_lint: ^7.0.0+1 From c6775760283a6beca2c6a56d3b8b446922089217 Mon Sep 17 00:00:00 2001 From: Bartek Pacia Date: Thu, 23 Nov 2023 10:21:33 +0100 Subject: [PATCH 2/6] gitignore all custom_lint.log files --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 41d9b9ea1..d765fe734 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ *.iml /pubspec.lock pubspec_overrides.yaml +custom_lint.log From a8e215458da858042c13cef723f827991dee0a8c Mon Sep 17 00:00:00 2001 From: Bartek Pacia Date: Thu, 23 Nov 2023 10:22:53 +0100 Subject: [PATCH 3/6] fix new lint warnings --- .../devtools_service_extensions.dart | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/patrol/lib/src/devtools_service_extensions/devtools_service_extensions.dart b/packages/patrol/lib/src/devtools_service_extensions/devtools_service_extensions.dart index 86e6d549f..109a02d19 100644 --- a/packages/patrol/lib/src/devtools_service_extensions/devtools_service_extensions.dart +++ b/packages/patrol/lib/src/devtools_service_extensions/devtools_service_extensions.dart @@ -1,6 +1,7 @@ // ignore_for_file: public_member_api_docs import 'dart:convert'; + import 'package:flutter/widgets.dart'; import 'package:http/http.dart' as http; import 'package:patrol/src/native/contracts/contracts.dart'; @@ -47,9 +48,9 @@ class DevtoolsServiceExtensions { 'result': res, 'success': true, }; - } catch (e, t) { + } catch (err, st) { return { - 'result': '$e $t', + 'result': '$err $st', 'success': false, }; } From 229d88caa9061a1bef0f7b5c79ca244f6e91be9d Mon Sep 17 00:00:00 2001 From: Bartek Pacia Date: Thu, 23 Nov 2023 10:23:07 +0100 Subject: [PATCH 4/6] update prepare-* workflows to run custom_lint --- .github/workflows/adb-prepare.yaml | 7 +++++-- .github/workflows/patrol-prepare.yaml | 6 ++++-- .github/workflows/patrol_cli-prepare.yaml | 7 +++++-- .github/workflows/patrol_devtools_extension-prepare.yaml | 6 ++++-- .github/workflows/patrol_finders-prepare.yaml | 6 ++++-- .github/workflows/patrol_gen-prepare.yaml | 6 ++++-- 6 files changed, 26 insertions(+), 12 deletions(-) diff --git a/.github/workflows/adb-prepare.yaml b/.github/workflows/adb-prepare.yaml index fd5d0bc37..1d3a664fc 100644 --- a/.github/workflows/adb-prepare.yaml +++ b/.github/workflows/adb-prepare.yaml @@ -35,8 +35,11 @@ jobs: - name: dart test run: dart test - - name: dart analyze - run: dart analyze + - name: Run analyzer + if: success() || failure() + run: | + dart analyze + dart run custom_lint - name: dart format run: dart format --set-exit-if-changed . diff --git a/.github/workflows/patrol-prepare.yaml b/.github/workflows/patrol-prepare.yaml index bdc5337c2..57b24706d 100644 --- a/.github/workflows/patrol-prepare.yaml +++ b/.github/workflows/patrol-prepare.yaml @@ -226,9 +226,11 @@ jobs: if: success() || failure() run: flutter test --coverage - - name: flutter analyze + - name: Run analyzer if: success() || failure() - run: flutter analyze + run: | + flutter analyze + dart run custom_lint - name: dart format if: success() || failure() diff --git a/.github/workflows/patrol_cli-prepare.yaml b/.github/workflows/patrol_cli-prepare.yaml index 4ffef45c3..322afdb3d 100644 --- a/.github/workflows/patrol_cli-prepare.yaml +++ b/.github/workflows/patrol_cli-prepare.yaml @@ -49,8 +49,11 @@ jobs: dart test --coverage coverage dart run coverage:format_coverage --lcov --in coverage --out coverage/lcov.info --report-on lib - - name: dart analyze - run: dart analyze + - name: Run analyzer + if: success() || failure() + run: | + flutter analyze + dart run custom_lint - name: dart format run: dart format --set-exit-if-changed . diff --git a/.github/workflows/patrol_devtools_extension-prepare.yaml b/.github/workflows/patrol_devtools_extension-prepare.yaml index c0236d58d..734a557fa 100644 --- a/.github/workflows/patrol_devtools_extension-prepare.yaml +++ b/.github/workflows/patrol_devtools_extension-prepare.yaml @@ -38,9 +38,11 @@ jobs: if: success() || failure() run: flutter test --coverage - - name: flutter analyze + - name: Run analyzer if: success() || failure() - run: flutter analyze + run: | + flutter analyze + dart run custom_lint - name: dart format if: success() || failure() diff --git a/.github/workflows/patrol_finders-prepare.yaml b/.github/workflows/patrol_finders-prepare.yaml index 9a846a009..780131fb8 100644 --- a/.github/workflows/patrol_finders-prepare.yaml +++ b/.github/workflows/patrol_finders-prepare.yaml @@ -38,9 +38,11 @@ jobs: if: success() || failure() run: flutter test --coverage - - name: flutter analyze + - name: Run analyzer if: success() || failure() - run: flutter analyze + run: | + flutter analyze + dart run custom_lint - name: dart format if: success() || failure() diff --git a/.github/workflows/patrol_gen-prepare.yaml b/.github/workflows/patrol_gen-prepare.yaml index 86653994c..cf7ad6043 100644 --- a/.github/workflows/patrol_gen-prepare.yaml +++ b/.github/workflows/patrol_gen-prepare.yaml @@ -32,9 +32,11 @@ jobs: - name: dart pub get run: dart pub get - - name: dart analyze + - name: Run analyzer if: success() || failure() - run: dart analyze + run: | + dart analyze + dart run custom_lint - name: dart format if: success() || failure() From 4f775d04650a6f1360c4023c775d2ec8f85cbdc2 Mon Sep 17 00:00:00 2001 From: Bartek Pacia Date: Thu, 23 Nov 2023 10:52:17 +0100 Subject: [PATCH 5/6] delete analysis_options in directories that do not have pubspec.yaml This is needed because of bug in custom_lint: https://github.com/invertase/dart_custom_lint/issues/148 --- .../patrol_cli/test/analysis_options.yaml | 6 --- .../test/crossplatform/app_options_test.dart | 20 +++---- .../lib/api/contracts.dart | 4 +- .../lib/api/patrol_service_extension_api.dart | 6 +-- .../example/test/analysis_options.yaml | 6 --- .../patrol_finders/test/analysis_options.yaml | 6 --- .../test/patrol_finder_test.dart | 42 +++++++-------- .../test/patrol_tester_test.dart | 53 ++++++++++--------- packages/patrol_finders/test/smoke_test.dart | 8 +-- 9 files changed, 66 insertions(+), 85 deletions(-) delete mode 100644 packages/patrol_cli/test/analysis_options.yaml delete mode 100644 packages/patrol_finders/example/test/analysis_options.yaml delete mode 100644 packages/patrol_finders/test/analysis_options.yaml diff --git a/packages/patrol_cli/test/analysis_options.yaml b/packages/patrol_cli/test/analysis_options.yaml deleted file mode 100644 index d28d1dab8..000000000 --- a/packages/patrol_cli/test/analysis_options.yaml +++ /dev/null @@ -1,6 +0,0 @@ -include: package:leancode_lint/analysis_options.yaml - -linter: - rules: - prefer_const_constructors: false - discarded_futures: false diff --git a/packages/patrol_cli/test/crossplatform/app_options_test.dart b/packages/patrol_cli/test/crossplatform/app_options_test.dart index f362fb390..4eb01ad7d 100644 --- a/packages/patrol_cli/test/crossplatform/app_options_test.dart +++ b/packages/patrol_cli/test/crossplatform/app_options_test.dart @@ -10,13 +10,13 @@ void main() { group('correctly encodes default invocation', () { test('on Windows', () { - final flutterOptions = FlutterAppOptions( + const flutterOptions = FlutterAppOptions( target: r'C:\Users\john\app\integration_test\app_test.dart', buildMode: BuildMode.debug, flavor: null, dartDefines: {}, ); - options = AndroidAppOptions(flutter: flutterOptions); + options = const AndroidAppOptions(flutter: flutterOptions); final invocation = options.toGradleAssembleTestInvocation(isWindows: true); @@ -31,13 +31,13 @@ void main() { }); test('on macOS', () { - final flutterOpts = FlutterAppOptions( + const flutterOpts = FlutterAppOptions( target: '/Users/john/app/integration_test/app_test.dart', buildMode: BuildMode.release, flavor: null, dartDefines: {}, ); - options = AndroidAppOptions(flutter: flutterOpts); + options = const AndroidAppOptions(flutter: flutterOpts); final invocation = options.toGradleAssembleTestInvocation(isWindows: false); @@ -60,13 +60,13 @@ void main() { }; test('on Windows', () { - final flutterOpts = FlutterAppOptions( + const flutterOpts = FlutterAppOptions( target: r'C:\Users\john\app\integration_test\app_test.dart', buildMode: BuildMode.release, flavor: 'dev', dartDefines: dartDefines, ); - options = AndroidAppOptions(flutter: flutterOpts); + options = const AndroidAppOptions(flutter: flutterOpts); final invocation = options.toGradleAssembleTestInvocation(isWindows: true); @@ -82,13 +82,13 @@ void main() { }); test('on macOS', () { - final flutterOpts = FlutterAppOptions( + const flutterOpts = FlutterAppOptions( target: '/Users/john/app/integration_test/app_test.dart', buildMode: BuildMode.debug, flavor: 'dev', dartDefines: dartDefines, ); - options = AndroidAppOptions(flutter: flutterOpts); + options = const AndroidAppOptions(flutter: flutterOpts); final invocation = options.toGradleAssembleTestInvocation(isWindows: false); @@ -109,7 +109,7 @@ void main() { late IOSAppOptions options; group('correctly encodes default xcodebuild invocation for simulator', () { - final flutterOpts = FlutterAppOptions( + const flutterOpts = FlutterAppOptions( target: 'integration_test/app_test.dart', buildMode: BuildMode.debug, flavor: null, @@ -185,7 +185,7 @@ void main() { group( 'correctly encodes customized xcodebuild invocation for real device', () { - final flutterOpts = FlutterAppOptions( + const flutterOpts = FlutterAppOptions( target: 'integration_test/app_test.dart', buildMode: BuildMode.release, flavor: 'prod', diff --git a/packages/patrol_devtools_extension/lib/api/contracts.dart b/packages/patrol_devtools_extension/lib/api/contracts.dart index 6bd6bd882..45be03ce5 100644 --- a/packages/patrol_devtools_extension/lib/api/contracts.dart +++ b/packages/patrol_devtools_extension/lib/api/contracts.dart @@ -300,9 +300,9 @@ class NativeView with EquatableMixin { final bool focused; final bool enabled; final int? childCount; - //TODO: rename to "resourceId" for consistency + // TODO: rename to "resourceId" for consistency final String? resourceName; - //TODO: rename to "pkg" for consistency + // TODO: rename to "pkg" for consistency final String? applicationPackage; final List children; diff --git a/packages/patrol_devtools_extension/lib/api/patrol_service_extension_api.dart b/packages/patrol_devtools_extension/lib/api/patrol_service_extension_api.dart index e4c9de799..93bca7545 100644 --- a/packages/patrol_devtools_extension/lib/api/patrol_service_extension_api.dart +++ b/packages/patrol_devtools_extension/lib/api/patrol_service_extension_api.dart @@ -58,7 +58,7 @@ class PatrolServiceExtensionApi { final extensionName = 'ext.flutter.$methodName'; final r = await _service.callServiceExtension( extensionName, - isolateId: _isolate.value!.id, //Verify + isolateId: _isolate.value!.id, args: args, ); @@ -70,8 +70,8 @@ class PatrolServiceExtensionApi { final res = resultFactory(json['result']); return ApiSuccess(res); - } catch (e, t) { - return ApiFailure(e, t); + } catch (err, st) { + return ApiFailure(err, st); } } } diff --git a/packages/patrol_finders/example/test/analysis_options.yaml b/packages/patrol_finders/example/test/analysis_options.yaml deleted file mode 100644 index 98093f93d..000000000 --- a/packages/patrol_finders/example/test/analysis_options.yaml +++ /dev/null @@ -1,6 +0,0 @@ -include: package:leancode_lint/analysis_options.yaml - -linter: - rules: - prefer_const_constructors: false - avoid_print: false diff --git a/packages/patrol_finders/test/analysis_options.yaml b/packages/patrol_finders/test/analysis_options.yaml deleted file mode 100644 index fef38b031..000000000 --- a/packages/patrol_finders/test/analysis_options.yaml +++ /dev/null @@ -1,6 +0,0 @@ -include: package:leancode_lint/analysis_options_package.yaml - -linter: - rules: - prefer_const_constructors: false - prefer_const_literals_to_create_immutables: false diff --git a/packages/patrol_finders/test/patrol_finder_test.dart b/packages/patrol_finders/test/patrol_finder_test.dart index 54d7b13c3..a57f9cc22 100644 --- a/packages/patrol_finders/test/patrol_finder_test.dart +++ b/packages/patrol_finders/test/patrol_finder_test.dart @@ -8,9 +8,9 @@ import 'package:patrol_finders/src/custom_finders/custom_finders.dart'; void main() { group('PatrolFinder', () { group('finds widget by', () { - final app = MaterialApp( + const app = MaterialApp( home: Row( - children: const [ + children: [ Icon(Icons.front_hand, key: ValueKey({'key': 'icon'})), Text('Hello', key: Key('helloText')), ], @@ -580,10 +580,10 @@ void main() { patrolWidgetTest('scrolls to existing and visible widget', ($) async { await $.pumpWidget( - MaterialApp( + const MaterialApp( home: SingleChildScrollView( child: Column( - children: const [Text('some text')], + children: [Text('some text')], ), ), ), @@ -603,18 +603,18 @@ void main() { MaterialApp( home: LayoutBuilder( builder: (_, constraints) { - return Column( + return const Column( children: [ SingleChildScrollView( scrollDirection: Axis.horizontal, child: Column( - children: const [Text('text 1')], + children: [Text('text 1')], ), ), SingleChildScrollView( scrollDirection: Axis.horizontal, child: Column( - children: const [Text('text 2')], + children: [Text('text 2')], ), ), ], @@ -643,18 +643,18 @@ void main() { MaterialApp( home: LayoutBuilder( builder: (_, constraints) { - return Column( + return const Column( children: [ SingleChildScrollView( scrollDirection: Axis.horizontal, child: Column( - children: const [ + children: [ Text('text 1'), Text('text 1'), ], ), ), - const SingleChildScrollView( + SingleChildScrollView( scrollDirection: Axis.horizontal, child: Text('text 1'), ), @@ -862,13 +862,11 @@ void main() { child: StatefulBuilder( builder: (context, setState) { return Column( - key: Key('column'), + key: const Key('column'), children: [ - Row( + const Row( children: [ - Column( - children: [], - ), + Column(), ], ), Text('count: $count'), @@ -973,9 +971,9 @@ void main() { group('at()', () { patrolWidgetTest('finds single widget at index', ($) async { await $.pumpWidget( - MaterialApp( + const MaterialApp( home: Column( - children: const [Text('text'), Text('text'), Text('text')], + children: [Text('text'), Text('text'), Text('text')], ), ), ); @@ -987,7 +985,7 @@ void main() { patrolWidgetTest("works identically to Flutter's finders", ($) async { await $.pumpWidget( - MaterialApp(home: Column(children: const [Text('text')])), + const MaterialApp(home: Column(children: [Text('text')])), ); expect($(Text).at(0).toString(), find.byType(Text).at(0).toString()); @@ -1013,8 +1011,8 @@ void main() { group('first', () { patrolWidgetTest('finds first widget', ($) async { await $.pumpWidget( - MaterialApp( - home: Column(children: const [Text('text'), Text('text')]), + const MaterialApp( + home: Column(children: [Text('text'), Text('text')]), ), ); @@ -1053,8 +1051,8 @@ void main() { group('last', () { patrolWidgetTest('finds last widget', ($) async { await $.pumpWidget( - MaterialApp( - home: Column(children: const [Text('text'), Text('text')]), + const MaterialApp( + home: Column(children: [Text('text'), Text('text')]), ), ); diff --git a/packages/patrol_finders/test/patrol_tester_test.dart b/packages/patrol_finders/test/patrol_tester_test.dart index e5a813090..3fb2a8635 100644 --- a/packages/patrol_finders/test/patrol_tester_test.dart +++ b/packages/patrol_finders/test/patrol_tester_test.dart @@ -253,10 +253,10 @@ void main() { patrolWidgetTest('drags to existing and visible widget', (tester) async { await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: SingleChildScrollView( child: Column( - children: const [Text('some text')], + children: [Text('some text')], ), ), ), @@ -346,13 +346,13 @@ void main() { 'drags to existing and visible widget in the first Scrollable', (tester) async { await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: Column( children: [ SingleChildScrollView( scrollDirection: Axis.horizontal, child: Column( - children: const [ + children: [ Text('text 1'), Text('text 1'), ], @@ -361,7 +361,7 @@ void main() { SingleChildScrollView( scrollDirection: Axis.horizontal, child: Column( - children: const [Text('text 2')], + children: [Text('text 2')], ), ), ], @@ -435,10 +435,10 @@ void main() { patrolWidgetTest('drags to existing and visible widget', (tester) async { await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: SingleChildScrollView( child: Column( - children: const [Text('some text')], + children: [Text('some text')], ), ), ), @@ -522,12 +522,12 @@ void main() { 'drags to existing and visible widget in the first Scrollable', (tester) async { await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: Column( children: [ SingleChildScrollView( child: Column( - children: const [ + children: [ Text('text 1'), Text('text 1'), ], @@ -535,7 +535,7 @@ void main() { ), SingleChildScrollView( child: Column( - children: const [Text('text 2')], + children: [Text('text 2')], ), ), ], @@ -578,13 +578,13 @@ void main() { return const CircularProgressIndicator(); } - return Column( + return const Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ SingleChildScrollView( scrollDirection: Axis.horizontal, child: Column( - children: const [ + children: [ SizedBox(width: 2000), Text('text 1'), Text('text 1'), @@ -594,7 +594,7 @@ void main() { SingleChildScrollView( scrollDirection: Axis.horizontal, child: Column( - children: const [ + children: [ SizedBox(width: 2000), Text('text 2'), ], @@ -718,10 +718,10 @@ void main() { patrolWidgetTest('scrolls to existing and visible widget', (tester) async { await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: SingleChildScrollView( child: Column( - children: const [Text('some text')], + children: [Text('some text')], ), ), ), @@ -738,19 +738,19 @@ void main() { 'scrolls to existing and visible widget in the first Scrollable', (tester) async { await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: Column( children: [ SingleChildScrollView( scrollDirection: Axis.horizontal, child: Column( - children: const [Text('text 1')], + children: [Text('text 1')], ), ), SingleChildScrollView( scrollDirection: Axis.horizontal, child: Column( - children: const [Text('text 2')], + children: [Text('text 2')], ), ), ], @@ -774,19 +774,19 @@ void main() { 'many same widgets are present', (tester) async { await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: Column( children: [ SingleChildScrollView( scrollDirection: Axis.horizontal, child: Column( - children: const [ + children: [ Text('text 1'), Text('text 1'), ], ), ), - const SingleChildScrollView( + SingleChildScrollView( scrollDirection: Axis.horizontal, child: Text('text 1'), ), @@ -960,7 +960,7 @@ void main() { builder: (context, setState) { return Column( children: [ - CircularProgressIndicator(), + const CircularProgressIndicator(), Text('count: $count'), ElevatedButton( onPressed: () => setState(() => count++), @@ -988,7 +988,7 @@ void main() { ElevatedButton( onPressed: () => setState(() { state = 1; - Timer(Duration(seconds: 5), () { + Timer(const Duration(seconds: 5), () { setState(() { state = 0; count++; @@ -999,7 +999,7 @@ void main() { textStyle: const TextStyle(fontSize: 20), ), child: state != 0 - ? CircularProgressIndicator() + ? const CircularProgressIndicator() : const Text('Enabled button'), ), ], @@ -1016,7 +1016,8 @@ void main() { await $.pumpWidget(appWithInfiniteAnimation); // 10 seconds is verbatim here to guard against changing the default - final end = $.tester.binding.clock.now().add(Duration(seconds: 10)); + final end = + $.tester.binding.clock.now().add(const Duration(seconds: 10)); await $(ElevatedButton).tap(settlePolicy: SettlePolicy.trySettle); @@ -1033,7 +1034,7 @@ void main() { await $(ElevatedButton).tap( settlePolicy: SettlePolicy.trySettle, - settleTimeout: Duration(seconds: 10), + settleTimeout: const Duration(seconds: 10), ); expect($('count: 1'), findsOneWidget); diff --git a/packages/patrol_finders/test/smoke_test.dart b/packages/patrol_finders/test/smoke_test.dart index 118b199b0..c4d4f5592 100644 --- a/packages/patrol_finders/test/smoke_test.dart +++ b/packages/patrol_finders/test/smoke_test.dart @@ -111,10 +111,10 @@ void main() { ($) async { await expectLater( () async => $.pumpWidgetAndSettle( - MaterialApp( + const MaterialApp( home: Scaffold( body: IndexedStack( - children: const [ + children: [ Center(child: Text('first child')), Center(child: CircularProgressIndicator()), ], @@ -176,9 +176,9 @@ void main() { Future smallPump(PatrolTester $) async { await $.pumpWidgetAndSettle( - MaterialApp( + const MaterialApp( home: Row( - children: const [ + children: [ Icon(Icons.front_hand), Text('Hello', key: Key('helloText')), ], From 28a9ebd78ced3ac1f9a531d7ba36e41207e07ae3 Mon Sep 17 00:00:00 2001 From: Bartek Pacia Date: Thu, 23 Nov 2023 11:29:03 +0100 Subject: [PATCH 6/6] fix tests --- .../patrol_cli/test/commands/patrol_command_runner_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/patrol_cli/test/commands/patrol_command_runner_test.dart b/packages/patrol_cli/test/commands/patrol_command_runner_test.dart index 790303d49..3340d061d 100644 --- a/packages/patrol_cli/test/commands/patrol_command_runner_test.dart +++ b/packages/patrol_cli/test/commands/patrol_command_runner_test.dart @@ -34,7 +34,7 @@ void main() { ).thenAnswer((_) async => version); commandRunner = PatrolCommandRunner( - platform: FakePlatform(), + platform: FakePlatform(environment: {}), processManager: FakeProcessManager(), pubUpdater: pubUpdater, fs: MemoryFileSystem.test(),