Skip to content

Commit 850ea6d

Browse files
authored
Update for modern analysis (flutter#127)
This should improve the package's health score on Pub
1 parent 4cc8554 commit 850ea6d

Some content is hidden

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

67 files changed

+1019
-900
lines changed

analysis_options.yaml

Lines changed: 129 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,166 @@
11
analyzer:
22
strong-mode:
33
implicit-dynamic: false
4-
language:
5-
enableSuperMixins: true
64
errors:
75
# treat missing required parameters as a warning (not a hint)
86
missing_required_param: warning
9-
# Allow having TODOs in the code
7+
# treat missing returns as a warning (not a hint)
8+
missing_return: warning
9+
# allow having TODOs in the code
1010
todo: ignore
11+
# Ignore analyzer hints for updating pubspecs when using Future or
12+
# Stream and not importing dart:async
13+
# Please see https://github.com/flutter/flutter/pull/24528 for details.
14+
sdk_version_async_exported_from_core: ignore
1115

1216
linter:
1317
rules:
1418
# these rules are documented on and in the same order as
1519
# the Dart Lint rules page to make maintenance easier
16-
# http://dart-lang.github.io/linter/lints/
17-
18-
# === error rules ===
19-
- avoid_empty_else
20-
- comment_references
21-
- cancel_subscriptions
22-
- close_sinks
23-
- control_flow_in_finally
24-
- empty_statements
25-
- hash_and_equals
26-
- invariant_booleans
27-
- iterable_contains_unrelated_type
28-
- list_remove_unrelated_type
29-
- literal_only_boolean_expressions
30-
- test_types_in_equals
31-
- throw_in_finally
32-
- unrelated_type_equality_checks
33-
- valid_regexps
34-
35-
# === style rules ===
20+
# https://github.com/dart-lang/linter/blob/master/example/all.yaml
3621
- always_declare_return_types
22+
- always_put_control_body_on_new_line
23+
# - always_put_required_named_parameters_first # we prefer having parameters in the same order as fields https://github.com/flutter/flutter/issues/10219
24+
- always_require_non_null_named_parameters
3725
- always_specify_types
3826
- annotate_overrides
39-
# TODO - avoid_as
27+
# - avoid_annotating_with_dynamic # conflicts with always_specify_types
28+
# - avoid_as
29+
- avoid_bool_literals_in_conditional_expressions
30+
# - avoid_catches_without_on_clauses # we do this commonly
31+
# - avoid_catching_errors # we do this commonly
32+
- avoid_classes_with_only_static_members
33+
# - avoid_double_and_int_checks # only useful when targeting JS runtime
34+
- avoid_empty_else
35+
- avoid_field_initializers_in_const_classes
36+
- avoid_function_literals_in_foreach_calls
37+
# - avoid_implementing_value_types # not yet tested
4038
- avoid_init_to_null
39+
# - avoid_js_rounded_ints # only useful when targeting JS runtime
40+
- avoid_null_checks_in_equality_operators
41+
# - avoid_positional_boolean_parameters # not yet tested
42+
# - avoid_private_typedef_functions # we prefer having typedef (discussion in https://github.com/flutter/flutter/pull/16356)
43+
- avoid_relative_lib_imports
44+
- avoid_renaming_method_parameters
4145
- avoid_return_types_on_setters
46+
# - avoid_returning_null # there are plenty of valid reasons to return null
47+
# - avoid_returning_null_for_future # not yet tested
48+
- avoid_returning_null_for_void
49+
# - avoid_returning_this # there are plenty of valid reasons to return this
50+
# - avoid_setters_without_getters # not yet tested
51+
# - avoid_shadowing_type_parameters # not yet tested
52+
# - avoid_single_cascade_in_expression_statements # not yet tested
53+
# - avoid_slow_async_io
54+
- avoid_types_as_parameter_names
55+
# - avoid_types_on_closure_parameters # conflicts with always_specify_types
56+
- avoid_unused_constructor_parameters
57+
- avoid_void_async
4258
- await_only_futures
4359
- camel_case_types
44-
- constant_identifier_names
60+
- cancel_subscriptions
61+
# - cascade_invocations # not yet tested
62+
# - close_sinks # not reliable enough
63+
# - comment_references # blocked on https://github.com/flutter/flutter/issues/20765
64+
# - constant_identifier_names # needs an opt-out https://github.com/dart-lang/linter/issues/204
4565
- control_flow_in_finally
66+
# - curly_braces_in_flow_control_structures # not yet tested
67+
# - diagnostic_describe_all_properties # not yet tested
68+
- directives_ordering
4669
- empty_catches
4770
- empty_constructor_bodies
71+
- empty_statements
72+
# - file_names # not yet tested
73+
- flutter_style_todos
74+
- hash_and_equals
4875
- implementation_imports
76+
# - invariant_booleans # too many false positives: https://github.com/dart-lang/linter/issues/811
77+
- iterable_contains_unrelated_type
78+
# - join_return_with_assignment # not yet tested
4979
- library_names
5080
- library_prefixes
81+
# - lines_longer_than_80_chars # not yet tested
82+
- list_remove_unrelated_type
83+
# - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/sdk/issues/34181
84+
- no_adjacent_strings_in_list
85+
- no_duplicate_case_values
5186
- non_constant_identifier_names
52-
- one_member_abstracts
53-
- only_throw_errors
87+
# - null_closures # not yet tested
88+
# - omit_local_variable_types # opposite of always_specify_types
89+
# - one_member_abstracts # too many false positives
90+
# - only_throw_errors # https://github.com/flutter/flutter/issues/5792
5491
- overridden_fields
5592
- package_api_docs
93+
- package_names
5694
- package_prefixed_library_names
95+
# - parameter_assignments # we do this commonly
96+
- prefer_adjacent_string_concatenation
97+
- prefer_asserts_in_initializer_lists
98+
# - prefer_asserts_with_message # not yet tested
99+
# - prefer_collection_literals
100+
- prefer_conditional_assignment
101+
- prefer_const_constructors
102+
- prefer_const_constructors_in_immutables
103+
- prefer_const_declarations
104+
- prefer_const_literals_to_create_immutables
105+
# - prefer_constructors_over_static_methods # not yet tested
106+
- prefer_contains
107+
# - prefer_double_quotes # opposite of prefer_single_quotes
108+
- prefer_equal_for_default_values
109+
# - prefer_expression_function_bodies # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#consider-using--for-short-functions-and-methods
110+
- prefer_final_fields
111+
# - prefer_final_in_for_each # not yet tested
112+
# - prefer_final_locals
113+
# - prefer_for_elements_to_map_fromIterable # not yet tested
114+
- prefer_foreach
115+
# - prefer_function_declarations_over_variables # not yet tested
116+
- prefer_generic_function_type_aliases
117+
# - prefer_if_elements_to_conditional_expressions # not yet tested
118+
- prefer_if_null_operators
119+
- prefer_initializing_formals
120+
- prefer_inlined_adds
121+
# - prefer_int_literals # not yet tested
122+
# - prefer_interpolation_to_compose_strings # not yet tested
123+
- prefer_is_empty
57124
- prefer_is_not_empty
125+
- prefer_iterable_whereType
126+
# - prefer_mixin # https://github.com/dart-lang/language/issues/32
127+
# - prefer_null_aware_operators # disable until NNBD, see https://github.com/flutter/flutter/pull/32711#issuecomment-492930932
128+
- prefer_single_quotes
129+
- prefer_spread_collections
130+
- prefer_typing_uninitialized_variables
131+
# - prefer_void_to_null
132+
# - provide_deprecation_message # not yet tested
58133
- public_member_api_docs
134+
- recursive_getters
59135
- slash_for_doc_comments
136+
# - sort_child_properties_last # not yet tested
60137
- sort_constructors_first
138+
- sort_pub_dependencies
61139
- sort_unnamed_constructors_first
62-
- super_goes_last
63-
- type_annotate_public_apis
140+
- test_types_in_equals
141+
- throw_in_finally
142+
# - type_annotate_public_apis # subset of always_specify_types
64143
- type_init_formals
65-
# TODO - unawaited_futures (https://github.com/dart-lang/linter/issues/419)
144+
# - unawaited_futures # too many false positives
145+
# - unnecessary_await_in_return # not yet tested
66146
- unnecessary_brace_in_string_interps
147+
- unnecessary_const
67148
- unnecessary_getters_setters
68-
69-
# === pub rules ===
70-
- package_names
149+
# - unnecessary_lambdas # has false positives: https://github.com/dart-lang/linter/issues/498
150+
- unnecessary_new
151+
- unnecessary_null_aware_assignments
152+
- unnecessary_null_in_if_null_operators
153+
- unnecessary_overrides
154+
- unnecessary_parenthesis
155+
- unnecessary_statements
156+
- unnecessary_this
157+
- unrelated_type_equality_checks
158+
# - unsafe_html # not yet tested
159+
- use_full_hex_values_for_flutter_colors
160+
# - use_function_type_syntax_for_parameters # not yet tested
161+
- use_rethrow_when_possible
162+
# - use_setters_to_change_properties # not yet tested
163+
# - use_string_buffers # has false positives: https://github.com/dart-lang/sdk/issues/34182
164+
# - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review
165+
- valid_regexps
166+
# - void_checks # not yet tested

packages/file/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#### 5.0.9
2+
3+
* Fix lints for project health
4+
15
#### 5.0.8
26

37
* Return Uint8List rather than List<int>.

packages/file/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Use the in-memory file system:
3333
```dart
3434
import 'package:file/memory.dart';
3535
36-
var fs = new MemoryFileSystem();
36+
var fs = MemoryFileSystem();
3737
```
3838

3939
Use the local file system (requires dart:io access):

packages/file/lib/src/backends/chroot/chroot_directory.dart

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ class _ChrootDirectory extends _ChrootFileSystemEntity<Directory, io.Directory>
1111
factory _ChrootDirectory.wrapped(
1212
ChrootFileSystem fs,
1313
Directory delegate, {
14-
bool relative: false,
14+
bool relative = false,
1515
}) {
1616
String localPath = fs._local(delegate.path, relative: relative);
17-
return new _ChrootDirectory(fs, localPath);
17+
return _ChrootDirectory(fs, localPath);
1818
}
1919

2020
@override
@@ -24,7 +24,7 @@ class _ChrootDirectory extends _ChrootFileSystemEntity<Directory, io.Directory>
2424
io.Directory _rawDelegate(String path) => fileSystem.delegate.directory(path);
2525

2626
@override
27-
Uri get uri => new Uri.directory(path);
27+
Uri get uri => Uri.directory(path);
2828

2929
@override
3030
Future<Directory> rename(String newPath) async {
@@ -83,7 +83,7 @@ class _ChrootDirectory extends _ChrootFileSystemEntity<Directory, io.Directory>
8383
}
8484

8585
@override
86-
Directory get absolute => new _ChrootDirectory(fileSystem, _absolutePath);
86+
Directory get absolute => _ChrootDirectory(fileSystem, _absolutePath);
8787

8888
@override
8989
Directory get parent {
@@ -95,7 +95,7 @@ class _ChrootDirectory extends _ChrootFileSystemEntity<Directory, io.Directory>
9595
}
9696

9797
@override
98-
Future<Directory> create({bool recursive: false}) async {
98+
Future<Directory> create({bool recursive = false}) async {
9999
if (_isLink) {
100100
switch (await fileSystem.type(path)) {
101101
case FileSystemEntityType.notFound:
@@ -106,15 +106,15 @@ class _ChrootDirectory extends _ChrootFileSystemEntity<Directory, io.Directory>
106106
// Nothing to do.
107107
return this;
108108
default:
109-
throw new AssertionError();
109+
throw AssertionError();
110110
}
111111
} else {
112112
return wrap(await delegate.create(recursive: recursive));
113113
}
114114
}
115115

116116
@override
117-
void createSync({bool recursive: false}) {
117+
void createSync({bool recursive = false}) {
118118
if (_isLink) {
119119
switch (fileSystem.typeSync(path)) {
120120
case FileSystemEntityType.notFound:
@@ -125,7 +125,7 @@ class _ChrootDirectory extends _ChrootFileSystemEntity<Directory, io.Directory>
125125
// Nothing to do.
126126
return;
127127
default:
128-
throw new AssertionError();
128+
throw AssertionError();
129129
}
130130
} else {
131131
delegate.createSync(recursive: recursive);
@@ -134,8 +134,8 @@ class _ChrootDirectory extends _ChrootFileSystemEntity<Directory, io.Directory>
134134

135135
@override
136136
Stream<FileSystemEntity> list({
137-
bool recursive: false,
138-
bool followLinks: true,
137+
bool recursive = false,
138+
bool followLinks = true,
139139
}) {
140140
Directory delegate = this.delegate;
141141
String dirname = delegate.path;
@@ -146,8 +146,8 @@ class _ChrootDirectory extends _ChrootFileSystemEntity<Directory, io.Directory>
146146

147147
@override
148148
List<FileSystemEntity> listSync({
149-
bool recursive: false,
150-
bool followLinks: true,
149+
bool recursive = false,
150+
bool followLinks = true,
151151
}) {
152152
Directory delegate = this.delegate;
153153
String dirname = delegate.path;
@@ -162,13 +162,13 @@ class _ChrootDirectory extends _ChrootFileSystemEntity<Directory, io.Directory>
162162
String relativePart = ctx.relative(entity.path, from: dirname);
163163
String entityPath = ctx.join(path, relativePart);
164164
if (entity is io.File) {
165-
return new _ChrootFile(fileSystem, entityPath);
165+
return _ChrootFile(fileSystem, entityPath);
166166
} else if (entity is io.Directory) {
167-
return new _ChrootDirectory(fileSystem, entityPath);
167+
return _ChrootDirectory(fileSystem, entityPath);
168168
} else if (entity is io.Link) {
169-
return new _ChrootLink(fileSystem, entityPath);
169+
return _ChrootLink(fileSystem, entityPath);
170170
}
171-
throw new FileSystemException('Unsupported type: $entity', entity.path);
171+
throw FileSystemException('Unsupported type: $entity', entity.path);
172172
}
173173

174174
@override

0 commit comments

Comments
 (0)