Skip to content

Commit edd4d12

Browse files
authored
Use custom lints (#1948)
* set up `custom_lint` in all packages * gitignore all custom_lint.log files * fix new lint warnings * update prepare-* workflows to run custom_lint * delete analysis_options in directories that do not have pubspec.yaml This is needed because of bug in custom_lint: invertase/dart_custom_lint#148 * fix tests
1 parent 856e5f2 commit edd4d12

30 files changed

+122
-112
lines changed

.github/workflows/adb-prepare.yaml

+5-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,11 @@ jobs:
3535
- name: dart test
3636
run: dart test
3737

38-
- name: dart analyze
39-
run: dart analyze
38+
- name: Run analyzer
39+
if: success() || failure()
40+
run: |
41+
dart analyze
42+
dart run custom_lint
4043
4144
- name: dart format
4245
run: dart format --set-exit-if-changed .

.github/workflows/patrol-prepare.yaml

+4-2
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,11 @@ jobs:
226226
if: success() || failure()
227227
run: flutter test --coverage
228228

229-
- name: flutter analyze
229+
- name: Run analyzer
230230
if: success() || failure()
231-
run: flutter analyze
231+
run: |
232+
flutter analyze
233+
dart run custom_lint
232234
233235
- name: dart format
234236
if: success() || failure()

.github/workflows/patrol_cli-prepare.yaml

+5-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,11 @@ jobs:
4949
dart test --coverage coverage
5050
dart run coverage:format_coverage --lcov --in coverage --out coverage/lcov.info --report-on lib
5151
52-
- name: dart analyze
53-
run: dart analyze
52+
- name: Run analyzer
53+
if: success() || failure()
54+
run: |
55+
flutter analyze
56+
dart run custom_lint
5457
5558
- name: dart format
5659
run: dart format --set-exit-if-changed .

.github/workflows/patrol_devtools_extension-prepare.yaml

+4-2
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ jobs:
3838
if: success() || failure()
3939
run: flutter test --coverage
4040

41-
- name: flutter analyze
41+
- name: Run analyzer
4242
if: success() || failure()
43-
run: flutter analyze
43+
run: |
44+
flutter analyze
45+
dart run custom_lint
4446
4547
- name: dart format
4648
if: success() || failure()

.github/workflows/patrol_finders-prepare.yaml

+4-2
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ jobs:
3838
if: success() || failure()
3939
run: flutter test --coverage
4040

41-
- name: flutter analyze
41+
- name: Run analyzer
4242
if: success() || failure()
43-
run: flutter analyze
43+
run: |
44+
flutter analyze
45+
dart run custom_lint
4446
4547
- name: dart format
4648
if: success() || failure()

.github/workflows/patrol_gen-prepare.yaml

+4-2
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@ jobs:
3232
- name: dart pub get
3333
run: dart pub get
3434

35-
- name: dart analyze
35+
- name: Run analyzer
3636
if: success() || failure()
37-
run: dart analyze
37+
run: |
38+
dart analyze
39+
dart run custom_lint
3840
3941
- name: dart format
4042
if: success() || failure()

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@
1010
*.iml
1111
/pubspec.lock
1212
pubspec_overrides.yaml
13+
custom_lint.log

packages/adb/analysis_options.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
include: package:leancode_lint/analysis_options_package.yaml
2+
3+
analyzer:
4+
plugins:
5+
- custom_lint

packages/adb/pubspec.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ environment:
88
sdk: '>=3.2.0 <4.0.0'
99

1010
dev_dependencies:
11+
custom_lint: ^0.5.7
1112
leancode_lint: ^7.0.0+1
1213
mocktail: ^1.0.1
1314
test: ^1.24.9

packages/patrol/analysis_options.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
include: package:leancode_lint/analysis_options_package.yaml
22

33
analyzer:
4+
plugins:
5+
- custom_lint
46
exclude:
57
- lib/**/*.g.dart

packages/patrol/example/integration_test/analysis_options.yaml

-6
This file was deleted.

packages/patrol/lib/src/devtools_service_extensions/devtools_service_extensions.dart

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// ignore_for_file: public_member_api_docs
22

33
import 'dart:convert';
4+
45
import 'package:flutter/widgets.dart';
56
import 'package:http/http.dart' as http;
67
import 'package:patrol/src/native/contracts/contracts.dart';
@@ -47,9 +48,9 @@ class DevtoolsServiceExtensions {
4748
'result': res,
4849
'success': true,
4950
};
50-
} catch (e, t) {
51+
} catch (err, st) {
5152
return <String, dynamic>{
52-
'result': '$e $t',
53+
'result': '$err $st',
5354
'success': false,
5455
};
5556
}

packages/patrol/pubspec.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ dependencies:
3131

3232
dev_dependencies:
3333
build_runner: ^2.4.6
34+
custom_lint: ^0.5.7
3435
json_serializable: ^6.7.1
3536
leancode_lint: ^7.0.0+1
3637

Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
include: package:leancode_lint/analysis_options.yaml
2+
3+
analyzer:
4+
plugins:
5+
- custom_lint

packages/patrol_cli/pubspec.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ dependencies:
3636
yaml: ^3.1.2
3737
dev_dependencies:
3838
build_runner: ^2.4.6
39+
custom_lint: ^0.5.7
3940
fake_async: ^1.3.1
4041
leancode_lint: ^7.0.0+1
4142
mocktail: ^1.0.1

packages/patrol_cli/test/analysis_options.yaml

-6
This file was deleted.

packages/patrol_cli/test/commands/patrol_command_runner_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ void main() {
3434
).thenAnswer((_) async => version);
3535

3636
commandRunner = PatrolCommandRunner(
37-
platform: FakePlatform(),
37+
platform: FakePlatform(environment: {}),
3838
processManager: FakeProcessManager(),
3939
pubUpdater: pubUpdater,
4040
fs: MemoryFileSystem.test(),

packages/patrol_cli/test/crossplatform/app_options_test.dart

+10-10
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ void main() {
1010

1111
group('correctly encodes default invocation', () {
1212
test('on Windows', () {
13-
final flutterOptions = FlutterAppOptions(
13+
const flutterOptions = FlutterAppOptions(
1414
target: r'C:\Users\john\app\integration_test\app_test.dart',
1515
buildMode: BuildMode.debug,
1616
flavor: null,
1717
dartDefines: {},
1818
);
19-
options = AndroidAppOptions(flutter: flutterOptions);
19+
options = const AndroidAppOptions(flutter: flutterOptions);
2020

2121
final invocation =
2222
options.toGradleAssembleTestInvocation(isWindows: true);
@@ -31,13 +31,13 @@ void main() {
3131
});
3232

3333
test('on macOS', () {
34-
final flutterOpts = FlutterAppOptions(
34+
const flutterOpts = FlutterAppOptions(
3535
target: '/Users/john/app/integration_test/app_test.dart',
3636
buildMode: BuildMode.release,
3737
flavor: null,
3838
dartDefines: {},
3939
);
40-
options = AndroidAppOptions(flutter: flutterOpts);
40+
options = const AndroidAppOptions(flutter: flutterOpts);
4141

4242
final invocation =
4343
options.toGradleAssembleTestInvocation(isWindows: false);
@@ -60,13 +60,13 @@ void main() {
6060
};
6161

6262
test('on Windows', () {
63-
final flutterOpts = FlutterAppOptions(
63+
const flutterOpts = FlutterAppOptions(
6464
target: r'C:\Users\john\app\integration_test\app_test.dart',
6565
buildMode: BuildMode.release,
6666
flavor: 'dev',
6767
dartDefines: dartDefines,
6868
);
69-
options = AndroidAppOptions(flutter: flutterOpts);
69+
options = const AndroidAppOptions(flutter: flutterOpts);
7070

7171
final invocation =
7272
options.toGradleAssembleTestInvocation(isWindows: true);
@@ -82,13 +82,13 @@ void main() {
8282
});
8383

8484
test('on macOS', () {
85-
final flutterOpts = FlutterAppOptions(
85+
const flutterOpts = FlutterAppOptions(
8686
target: '/Users/john/app/integration_test/app_test.dart',
8787
buildMode: BuildMode.debug,
8888
flavor: 'dev',
8989
dartDefines: dartDefines,
9090
);
91-
options = AndroidAppOptions(flutter: flutterOpts);
91+
options = const AndroidAppOptions(flutter: flutterOpts);
9292

9393
final invocation =
9494
options.toGradleAssembleTestInvocation(isWindows: false);
@@ -109,7 +109,7 @@ void main() {
109109
late IOSAppOptions options;
110110

111111
group('correctly encodes default xcodebuild invocation for simulator', () {
112-
final flutterOpts = FlutterAppOptions(
112+
const flutterOpts = FlutterAppOptions(
113113
target: 'integration_test/app_test.dart',
114114
buildMode: BuildMode.debug,
115115
flavor: null,
@@ -185,7 +185,7 @@ void main() {
185185
group(
186186
'correctly encodes customized xcodebuild invocation for real device',
187187
() {
188-
final flutterOpts = FlutterAppOptions(
188+
const flutterOpts = FlutterAppOptions(
189189
target: 'integration_test/app_test.dart',
190190
buildMode: BuildMode.release,
191191
flavor: 'prod',
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
include: package:leancode_lint/analysis_options.yaml
22

33
analyzer:
4+
plugins:
5+
- custom_lint
46
exclude:
57
- lib/**/*.g.dart

packages/patrol_devtools_extension/lib/api/contracts.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -300,9 +300,9 @@ class NativeView with EquatableMixin {
300300
final bool focused;
301301
final bool enabled;
302302
final int? childCount;
303-
//TODO: rename to "resourceId" for consistency
303+
// TODO: rename to "resourceId" for consistency
304304
final String? resourceName;
305-
//TODO: rename to "pkg" for consistency
305+
// TODO: rename to "pkg" for consistency
306306
final String? applicationPackage;
307307
final List<NativeView> children;
308308

packages/patrol_devtools_extension/lib/api/patrol_service_extension_api.dart

+3-3
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class PatrolServiceExtensionApi {
5858
final extensionName = 'ext.flutter.$methodName';
5959
final r = await _service.callServiceExtension(
6060
extensionName,
61-
isolateId: _isolate.value!.id, //Verify
61+
isolateId: _isolate.value!.id,
6262
args: args,
6363
);
6464

@@ -70,8 +70,8 @@ class PatrolServiceExtensionApi {
7070
final res = resultFactory(json['result']);
7171

7272
return ApiSuccess(res);
73-
} catch (e, t) {
74-
return ApiFailure(e, t);
73+
} catch (err, st) {
74+
return ApiFailure(err, st);
7575
}
7676
}
7777
}

packages/patrol_devtools_extension/pubspec.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ dependencies:
2121
vm_service: ^11.0.0
2222

2323
dev_dependencies:
24+
custom_lint: ^0.5.7
2425
flutter_test:
2526
sdk: flutter
2627
leancode_lint: ^7.0.0+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
include: package:leancode_lint/analysis_options_package.yaml
2+
3+
analyzer:
4+
plugins:
5+
- custom_lint

packages/patrol_finders/example/test/analysis_options.yaml

-6
This file was deleted.

packages/patrol_finders/test/analysis_options.yaml

-6
This file was deleted.

0 commit comments

Comments
 (0)