Skip to content

Commit bbb7d6e

Browse files
authored
Fix new analysis warnings, move to dart_flutter_team_lints (dart-archive/fake_async#58)
1 parent ff0cb24 commit bbb7d6e

File tree

6 files changed

+84
-147
lines changed

6 files changed

+84
-147
lines changed

pkgs/fake_async/.github/workflows/test-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
matrix:
4848
# Add macos-latest and/or windows-latest if relevant for this package.
4949
os: [ubuntu-latest]
50-
sdk: [2.12.0, dev]
50+
sdk: [2.17.0, dev]
5151
steps:
5252
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c
5353
- uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46

pkgs/fake_async/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.3.2-dev
2+
3+
* Require Dart 2.17.
4+
15
## 1.3.1
26

37
* Populate the pubspec `repository` field.
Lines changed: 3 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,22 @@
1-
include: package:lints/recommended.yaml
1+
include: package:dart_flutter_team_lints/analysis_options.yaml
22
analyzer:
33
language:
44
strict-casts: true
55

66
linter:
77
rules:
8-
- always_declare_return_types
9-
- annotate_overrides
108
- avoid_bool_literals_in_conditional_expressions
119
- avoid_classes_with_only_static_members
12-
- avoid_empty_else
13-
- avoid_function_literals_in_foreach_calls
14-
- avoid_init_to_null
15-
- avoid_null_checks_in_equality_operators
16-
- avoid_relative_lib_imports
17-
- avoid_renaming_method_parameters
18-
- avoid_return_types_on_setters
19-
- avoid_returning_null
20-
- avoid_returning_null_for_future
21-
- avoid_returning_null_for_void
2210
- avoid_returning_this
23-
- avoid_shadowing_type_parameters
24-
- avoid_single_cascade_in_expression_statements
25-
- avoid_types_as_parameter_names
2611
- avoid_unused_constructor_parameters
27-
- await_only_futures
28-
- camel_case_types
2912
- cancel_subscriptions
3013
- cascade_invocations
3114
- comment_references
32-
- constant_identifier_names
33-
- control_flow_in_finally
34-
- directives_ordering
35-
- empty_catches
36-
- empty_constructor_bodies
37-
- empty_statements
38-
- file_names
39-
- hash_and_equals
40-
- implementation_imports
41-
- iterable_contains_unrelated_type
4215
- join_return_with_assignment
43-
- library_names
44-
- library_prefixes
45-
- lines_longer_than_80_chars
46-
- list_remove_unrelated_type
4716
- literal_only_boolean_expressions
4817
- no_adjacent_strings_in_list
49-
- no_duplicate_case_values
50-
- non_constant_identifier_names
51-
- null_closures
52-
- omit_local_variable_types
53-
- only_throw_errors
54-
- overridden_fields
5518
- package_api_docs
56-
- package_names
57-
- package_prefixed_library_names
58-
- prefer_adjacent_string_concatenation
59-
# Wait for oldest supported SDK to be 2.2
60-
#- prefer_collection_literals
61-
- prefer_conditional_assignment
62-
#- prefer_const_constructors
63-
- prefer_contains
64-
- prefer_equal_for_default_values
65-
- prefer_final_fields
66-
#- prefer_final_locals
67-
- prefer_generic_function_type_aliases
68-
- prefer_initializing_formals
69-
- prefer_interpolation_to_compose_strings
70-
- prefer_is_empty
71-
- prefer_is_not_empty
72-
- prefer_null_aware_operators
73-
- prefer_single_quotes
74-
- prefer_typing_uninitialized_variables
75-
- recursive_getters
76-
- slash_for_doc_comments
19+
- prefer_const_constructors
20+
- prefer_final_locals
7721
- test_types_in_equals
78-
- throw_in_finally
79-
- type_init_formals
80-
- unawaited_futures
8122
- unnecessary_await_in_return
82-
- unnecessary_brace_in_string_interps
83-
- unnecessary_const
84-
- unnecessary_getters_setters
85-
- unnecessary_lambdas
86-
- unnecessary_new
87-
- unnecessary_null_aware_assignments
88-
- unnecessary_parenthesis
89-
- unnecessary_statements
90-
- unnecessary_this
91-
- unrelated_type_equality_checks
92-
- use_function_type_syntax_for_parameters
93-
- use_rethrow_when_possible
94-
- valid_regexps
95-
- void_checks

pkgs/fake_async/lib/fake_async.dart

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class FakeAsync {
103103
/// Note: it's usually more convenient to use [fakeAsync] rather than creating
104104
/// a [FakeAsync] object and calling [run] manually.
105105
FakeAsync({DateTime? initialTime, this.includeTimerStackTrace = true}) {
106-
var nonNullInitialTime = initialTime ?? clock.now();
106+
final nonNullInitialTime = initialTime ?? clock.now();
107107
_clock = Clock(() => nonNullInitialTime.add(elapsed));
108108
}
109109

@@ -156,7 +156,7 @@ class FakeAsync {
156156
}
157157

158158
_elapsed += duration;
159-
var elapsingTo = _elapsingTo;
159+
final elapsingTo = _elapsingTo;
160160
if (elapsingTo != null && _elapsed > elapsingTo) _elapsingTo = _elapsed;
161161
}
162162

@@ -169,7 +169,7 @@ class FakeAsync {
169169
/// The [`clock`][] property will be set to a clock that reports the fake
170170
/// elapsed time. By default, it starts at the time the [FakeAsync] was
171171
/// created (according to [`clock.now()`][]), but this can be controlled by
172-
/// passing `initialTime` to [new FakeAsync].
172+
/// passing `initialTime` to [FakeAsync.new].
173173
///
174174
/// [`clock`]: https://www.dartdocs.org/documentation/clock/latest/clock/clock.html
175175
/// [`clock.now()`]: https://www.dartdocs.org/documentation/clock/latest/clock/Clock/now.html
@@ -210,7 +210,7 @@ class FakeAsync {
210210
void flushTimers(
211211
{Duration timeout = const Duration(hours: 1),
212212
bool flushPeriodicTimers = true}) {
213-
var absoluteTimeout = _elapsed + timeout;
213+
final absoluteTimeout = _elapsed + timeout;
214214
_fireTimersWhile((timer) {
215215
if (timer._nextCall > absoluteTimeout) {
216216
// TODO(nweiz): Make this a [TimeoutException].
@@ -237,7 +237,7 @@ class FakeAsync {
237237
for (;;) {
238238
if (_timers.isEmpty) break;
239239

240-
var timer = minBy(_timers, (FakeTimer timer) => timer._nextCall)!;
240+
final timer = minBy(_timers, (FakeTimer timer) => timer._nextCall)!;
241241
if (!predicate(timer)) break;
242242

243243
_elapseTo(timer._nextCall);
@@ -249,7 +249,7 @@ class FakeAsync {
249249
/// Creates a new timer controlled by `this` that fires [callback] after
250250
/// [duration] (or every [duration] if [periodic] is `true`).
251251
Timer _createTimer(Duration duration, Function callback, bool periodic) {
252-
var timer = FakeTimer._(duration, callback, periodic, this,
252+
final timer = FakeTimer._(duration, callback, periodic, this,
253253
includeStackTrace: includeTimerStackTrace);
254254
_timers.add(timer);
255255
return timer;
@@ -320,10 +320,12 @@ class FakeTimer implements Timer {
320320
assert(isActive);
321321
_tick++;
322322
if (isPeriodic) {
323+
// ignore: avoid_dynamic_calls
323324
_callback(this);
324325
_nextCall += duration;
325326
} else {
326327
cancel();
328+
// ignore: avoid_dynamic_calls
327329
_callback();
328330
}
329331
}

pkgs/fake_async/pubspec.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
name: fake_async
2-
version: 1.3.1
2+
version: 1.3.2-dev
33
description: >-
44
Fake asynchronous events such as timers and microtasks for deterministic
55
testing.
66
repository: https://github.com/dart-lang/fake_async
77

88
environment:
9-
sdk: ">=2.12.0 <3.0.0"
9+
sdk: ">=2.17.0 <3.0.0"
1010

1111
dependencies:
1212
clock: ^1.1.0
1313
collection: ^1.15.0
1414

1515
dev_dependencies:
1616
async: ^2.5.0
17-
lints: ^1.0.0
17+
dart_flutter_team_lints: ^0.1.0
1818
test: ^1.16.0

0 commit comments

Comments
 (0)