Skip to content

Commit 70da5be

Browse files
authored
refactor: Apply ubuntu lints to all packages (#340)
* refactor: Use ubuntu_lints * refactor: Fixes to follow the ubuntu_lints rules * ci: Bump to Flutter 3.16 * fix: Loosen up types where necessary * ci: Try one 3.13.x * test: Bump epsilon to 3 for ison baseline alignment
1 parent 762f05c commit 70da5be

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+109
-282
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
workflow_dispatch:
99

1010
env:
11-
FLUTTER_VERSION: '3.13.x'
11+
FLUTTER_VERSION: '3.16.x'
1212

1313
jobs:
1414
analyze:
Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1 @@
1-
include: package:lints/recommended.yaml
2-
3-
analyzer:
4-
exclude:
5-
- "**/*.g.dart"
6-
- "**/*.mocks.dart"
7-
8-
language:
9-
strict-casts: true
10-
strict-raw-types: true
11-
12-
linter:
13-
rules:
14-
always_declare_return_types: true
15-
avoid_catches_without_on_clauses: true
16-
avoid_equals_and_hash_code_on_mutable_classes: true
17-
avoid_types_on_closure_parameters: true
18-
cancel_subscriptions: true
19-
depend_on_referenced_packages: true
20-
directives_ordering: true
21-
eol_at_end_of_file: true
22-
omit_local_variable_types: true
23-
prefer_asserts_in_initializer_lists: true
24-
prefer_const_constructors: true
25-
prefer_final_in_for_each: true
26-
prefer_final_locals: true
27-
prefer_null_aware_method_calls: true
28-
prefer_null_aware_operators: true
29-
prefer_relative_imports: true
30-
prefer_single_quotes: true
31-
sort_unnamed_constructors_first: true
32-
sort_pub_dependencies: true
33-
type_annotate_public_apis: true
34-
unawaited_futures: true
35-
unnecessary_lambdas: true
36-
unnecessary_late: true
37-
unnecessary_parenthesis: true
38-
use_named_constants: true
1+
include: package:ubuntu_lints/analysis_options.yaml

packages/platform_linux/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ dependencies:
1414
platform: ^3.1.0
1515

1616
dev_dependencies:
17-
lints: ^2.0.0
17+
ubuntu_lints: ^0.1.0
1818
mockito: ^5.4.2
1919
test: ^1.21.0
Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1 @@
1-
include: package:flutter_lints/flutter.yaml
2-
3-
analyzer:
4-
language:
5-
strict-casts: true
6-
strict-raw-types: true
7-
8-
linter:
9-
rules:
10-
always_declare_return_types: true
11-
avoid_catches_without_on_clauses: true
12-
avoid_classes_with_only_static_members: false
13-
avoid_equals_and_hash_code_on_mutable_classes: true
14-
avoid_redundant_argument_values: true
15-
avoid_types_on_closure_parameters: true
16-
cancel_subscriptions: true
17-
depend_on_referenced_packages: true
18-
directives_ordering: true
19-
eol_at_end_of_file: true
20-
omit_local_variable_types: true
21-
prefer_asserts_in_initializer_lists: true
22-
prefer_const_constructors: true
23-
prefer_final_in_for_each: true
24-
prefer_final_locals: true
25-
prefer_null_aware_method_calls: true
26-
prefer_null_aware_operators: true
27-
prefer_relative_imports: true
28-
prefer_single_quotes: true
29-
sized_box_shrink_expand: true
30-
sized_box_for_whitespace: true
31-
sort_unnamed_constructors_first: true
32-
sort_pub_dependencies: true
33-
type_annotate_public_apis: true
34-
unawaited_futures: true
35-
unnecessary_lambdas: true
36-
unnecessary_late: true
37-
unnecessary_parenthesis: true
38-
use_decorated_box: true
39-
use_named_constants: true
40-
use_super_parameters: true
1+
include: package:ubuntu_lints/analysis_options.yaml

packages/safe_change_notifier/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ dependencies:
1717
state_notifier: ^0.7.0
1818

1919
dev_dependencies:
20-
flutter_lints: ^2.0.0
20+
ubuntu_lints: ^0.1.0
2121
flutter_test:
2222
sdk: flutter
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include: package:ubuntu_lints/analysis_options.yaml

packages/timezone_map/lib/src/exception.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@ class GeoException implements Exception {
88
const GeoException(this.message, [this.error]);
99

1010
/// Creates a new exception from a DIO response.
11-
factory GeoException.response(Response response) {
12-
final message = '${response.statusCode}: ${response.statusMessage}';
13-
return GeoException(message, response);
14-
}
11+
GeoException.response(Response<dynamic> response)
12+
: this('${response.statusCode}: ${response.statusMessage}', response);
1513

1614
/// A message describing the exception.
1715
final String message;

packages/timezone_map/lib/src/geoip.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ class GeoIP extends GeoSource {
5757
@override
5858
Future<void> cancel() async => _token?.cancel();
5959

60-
Future<Response> _sendRequest() {
61-
return _dio.get(url, cancelToken: _token = CancelToken());
60+
Future<Response<T>> _sendRequest<T>() {
61+
return _dio.get<T>(url, cancelToken: _token = CancelToken());
6262
}
6363

64-
Future<GeoLocation?> _handleResponse(Response response) {
64+
Future<GeoLocation?> _handleResponse<T>(Response<T> response) {
6565
if (response.statusCode != 200) {
6666
throw GeoException.response(response);
6767
}

packages/timezone_map/lib/src/geoname.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,17 @@ class Geoname extends GeoSource {
6666
@override
6767
Future<void> cancel() async => _token?.cancel();
6868

69-
Future<Response> _sendRequest(String query) {
70-
return _dio.get(
69+
Future<Response<T>> _sendRequest<T>(String query) {
70+
return _dio.get<T>(
7171
url,
7272
queryParameters: <String, String>{'query': query, ...?parameters},
7373
cancelToken: _token = CancelToken(),
7474
);
7575
}
7676

77-
Future<Iterable<GeoLocation>> _handleResponse(Response response) async {
77+
Future<Iterable<GeoLocation>> _handleResponse<T>(
78+
Response<T> response,
79+
) async {
7880
if (response.statusCode != 200) {
7981
throw GeoException.response(response);
8082
}

packages/timezone_map/lib/src/map.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class TimezoneMap extends StatelessWidget {
4242
final TimezoneMapSize size;
4343

4444
/// Requests all timezone map SVG assets to be pre-cached.
45-
static Future precacheAssets(BuildContext context) async {
45+
static Future<void> precacheAssets(BuildContext context) async {
4646
final bundle = DefaultAssetBundle.of(context);
4747
final manifest = await bundle
4848
.loadString('AssetManifest.json')
@@ -62,7 +62,7 @@ class TimezoneMap extends StatelessWidget {
6262
return precacheImage(asset, context);
6363
}
6464

65-
return Future.wait(manifest.keys.where(filterAsset).map(precacheAsset));
65+
await Future.wait(manifest.keys.where(filterAsset).map(precacheAsset));
6666
}
6767

6868
@override

0 commit comments

Comments
 (0)