Skip to content

Commit

Permalink
Use custom lints (#1948)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
bartekpacia authored Nov 23, 2023
1 parent 856e5f2 commit edd4d12
Show file tree
Hide file tree
Showing 30 changed files with 122 additions and 112 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/adb-prepare.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/patrol-prepare.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/patrol_cli-prepare.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/patrol_devtools_extension-prepare.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/patrol_finders-prepare.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/patrol_gen-prepare.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
*.iml
/pubspec.lock
pubspec_overrides.yaml
custom_lint.log
4 changes: 4 additions & 0 deletions packages/adb/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
include: package:leancode_lint/analysis_options_package.yaml

analyzer:
plugins:
- custom_lint
1 change: 1 addition & 0 deletions packages/adb/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions packages/patrol/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
include: package:leancode_lint/analysis_options_package.yaml

analyzer:
plugins:
- custom_lint
exclude:
- lib/**/*.g.dart

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -47,9 +48,9 @@ class DevtoolsServiceExtensions {
'result': res,
'success': true,
};
} catch (e, t) {
} catch (err, st) {
return <String, dynamic>{
'result': '$e $t',
'result': '$err $st',
'success': false,
};
}
Expand Down
1 change: 1 addition & 0 deletions packages/patrol/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions packages/patrol_cli/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
include: package:leancode_lint/analysis_options.yaml

analyzer:
plugins:
- custom_lint
1 change: 1 addition & 0 deletions packages/patrol_cli/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions packages/patrol_cli/test/analysis_options.yaml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void main() {
).thenAnswer((_) async => version);

commandRunner = PatrolCommandRunner(
platform: FakePlatform(),
platform: FakePlatform(environment: {}),
processManager: FakeProcessManager(),
pubUpdater: pubUpdater,
fs: MemoryFileSystem.test(),
Expand Down
20 changes: 10 additions & 10 deletions packages/patrol_cli/test/crossplatform/app_options_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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,
Expand Down Expand Up @@ -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',
Expand Down
2 changes: 2 additions & 0 deletions packages/patrol_devtools_extension/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
include: package:leancode_lint/analysis_options.yaml

analyzer:
plugins:
- custom_lint
exclude:
- lib/**/*.g.dart
4 changes: 2 additions & 2 deletions packages/patrol_devtools_extension/lib/api/contracts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<NativeView> children;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);

Expand All @@ -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);
}
}
}
1 change: 1 addition & 0 deletions packages/patrol_devtools_extension/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions packages/patrol_finders/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
include: package:leancode_lint/analysis_options_package.yaml

analyzer:
plugins:
- custom_lint
6 changes: 0 additions & 6 deletions packages/patrol_finders/example/test/analysis_options.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions packages/patrol_finders/test/analysis_options.yaml

This file was deleted.

Loading

0 comments on commit edd4d12

Please sign in to comment.