Skip to content

Commit 2247c1b

Browse files
committed
Switch from pendantic to dart_flutter_team_lints.
Tighten types accordingly.
1 parent e650eda commit 2247c1b

File tree

115 files changed

+1689
-1193
lines changed

Some content is hidden

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

115 files changed

+1689
-1193
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
# 9.0.0
4+
5+
- Tighten some types that were missing and inferred as `dynamic`. In particular,
6+
`updates` are now `void Function` instead of `Function`, and builder factories
7+
are now `Object Function()` instead of `Function`.
8+
- Use `dart_flutter_team_lints` instead of `pedantic`, fix lint violations.
9+
310
# 8.11.0
411

512
- Use `build ^3.0.0`.

benchmark/analysis_options.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
include: package:pedantic/analysis_options.yaml
1+
include: package:dart_flutter_team_lints/analysis_options.yaml

benchmark/lib/benchmark.dart

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,20 @@
22
// All rights reserved. Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
import 'package:benchmark/node.dart';
6-
import 'package:benchmark/simple_value.dart';
5+
import 'node.dart';
6+
import 'simple_value.dart';
77

88
void benchmark() {
99
benchmarkHashCode();
1010
benchmarkNestedRebuilds();
1111
}
1212

1313
void benchmarkHashCode() {
14-
final value = SimpleValue((b) => b
15-
..anInt = 0
16-
..aString = 'zero');
14+
final value = SimpleValue(
15+
(b) => b
16+
..anInt = 0
17+
..aString = 'zero',
18+
);
1719
_benchmark('hashCode', () => value.hashCode);
1820
}
1921

@@ -42,7 +44,7 @@ void _buildNested(NodeBuilder nodeBuilder, int depth) {
4244
}
4345
}
4446

45-
void _benchmark(String name, Function() function) {
47+
void _benchmark(String name, void Function() function) {
4648
// Warm up.
4749
for (var i = 0; i != 1000; ++i) {
4850
function();

benchmark/lib/node.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// All rights reserved. Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
library node;
6-
75
import 'package:built_value/built_value.dart';
86

97
part 'node.g.dart';
@@ -15,6 +13,6 @@ abstract class Node implements Built<Node, NodeBuilder> {
1513

1614
Node? get right;
1715

18-
factory Node([Function(NodeBuilder) updates]) = _$Node;
16+
factory Node([void Function(NodeBuilder) updates]) = _$Node;
1917
Node._();
2018
}

benchmark/lib/simple_value.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// All rights reserved. Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
library simple_value;
6-
75
import 'package:built_value/built_value.dart';
86

97
part 'simple_value.g.dart';
@@ -13,6 +11,7 @@ abstract class SimpleValue implements Built<SimpleValue, SimpleValueBuilder> {
1311

1412
String get aString;
1513

16-
factory SimpleValue([Function(SimpleValueBuilder) updates]) = _$SimpleValue;
14+
factory SimpleValue([void Function(SimpleValueBuilder) updates]) =
15+
_$SimpleValue;
1716
SimpleValue._();
1817
}

benchmark/pubspec.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ dependencies:
1515
dev_dependencies:
1616
build_runner: '>=1.0.0 <3.0.0'
1717
built_value_generator: ^8.11.0
18-
pedantic: ^1.4.0
18+
dart_flutter_team_lints: ^3.5.2
1919
quiver: '>=0.21.0 <4.0.0'
2020
test: ^1.0.0
21+
22+
dependency_overrides:
23+
built_value:
24+
path: ../built_value
25+
built_value_generator:
26+
path: ../built_value_generator

built_value/analysis_options.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
include: package:pedantic/analysis_options.yaml
1+
include: package:dart_flutter_team_lints/analysis_options.yaml
2+
3+
analyzer:
4+
errors:
5+
avoid_catching_errors: ignore

built_value/lib/async_serializer.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// All rights reserved. Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
import 'package:built_value/serializer.dart';
5+
import 'serializer.dart';
66

77
/// Deserializer for `BuiltList` that runs asynchronously.
88
///

built_value/lib/built_value.dart

Lines changed: 41 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ abstract class Built<V extends Built<V, B>, B extends Builder<V, B>> {
1818
///
1919
/// The implementation of this method will be generated for you by the
2020
/// built_value generator.
21-
V rebuild(Function(B) updates);
21+
V rebuild(void Function(B) updates);
2222

2323
/// Converts the instance to a builder [B].
2424
///
@@ -43,7 +43,7 @@ abstract class Builder<V extends Built<V, B>, B extends Builder<V, B>> {
4343
/// Applies updates.
4444
///
4545
/// [updates] is a function that takes a builder [B].
46-
void update(Function(B)? updates);
46+
void update(void Function(B)? updates);
4747

4848
/// Builds.
4949
///
@@ -117,15 +117,16 @@ class BuiltValue {
117117
/// to serialize with `@BuiltValueField(serialize: true)`.
118118
final bool defaultSerialize;
119119

120-
const BuiltValue(
121-
{this.instantiable = true,
122-
this.nestedBuilders = true,
123-
this.autoCreateNestedBuilders = true,
124-
this.comparableBuilders = false,
125-
this.generateBuilderOnSetField = false,
126-
this.wireName,
127-
this.defaultCompare = true,
128-
this.defaultSerialize = true});
120+
const BuiltValue({
121+
this.instantiable = true,
122+
this.nestedBuilders = true,
123+
this.autoCreateNestedBuilders = true,
124+
this.comparableBuilders = false,
125+
this.generateBuilderOnSetField = false,
126+
this.wireName,
127+
this.defaultCompare = true,
128+
this.defaultSerialize = true,
129+
});
129130
}
130131

131132
/// Annotation that was used to mark nullable Built Value fields.
@@ -156,20 +157,23 @@ class BuiltValueField {
156157
/// indicates the name is to be taken from the literal field name.
157158
final String? wireName;
158159

159-
/// Whether the field overrides the `nestedBuilders` setting from the class. Defaults to `null` which
160-
/// indicates the setting is to be taken from the `nestedBuilders` setting on the class.
160+
/// Whether the field overrides the `nestedBuilders` setting from the class.
161+
/// Defaults to `null` which indicates the setting is to be taken from the
162+
/// `nestedBuilders` setting on the class.
161163
final bool? nestedBuilder;
162164

163-
/// Whether the field overrides the `autoCreateNestedBuilders` setting from the class. Defaults to `null` which
164-
/// indicates the setting is to be taken from the `autoCreateNestedBuilders` setting on the class.
165+
/// Whether the field overrides the `autoCreateNestedBuilders` setting from
166+
/// the class. Defaults to `null` which indicates the setting is to be taken
167+
/// from the `autoCreateNestedBuilders` setting on the class.
165168
final bool? autoCreateNestedBuilder;
166169

167-
const BuiltValueField(
168-
{this.compare,
169-
this.serialize,
170-
this.wireName,
171-
this.nestedBuilder,
172-
this.autoCreateNestedBuilder});
170+
const BuiltValueField({
171+
this.compare,
172+
this.serialize,
173+
this.wireName,
174+
this.nestedBuilder,
175+
this.autoCreateNestedBuilder,
176+
});
173177
}
174178

175179
/// Optionally, annotate a Built Value `Serializer` getters with this to
@@ -187,8 +191,10 @@ class BuiltValueSerializer {
187191
188192
final bool serializeNulls;
189193

190-
const BuiltValueSerializer(
191-
{this.custom = false, this.serializeNulls = false});
194+
const BuiltValueSerializer({
195+
this.custom = false,
196+
this.serializeNulls = false,
197+
});
192198
}
193199

194200
/// Memoized annotation for Built Value getters.
@@ -235,8 +241,11 @@ class BuiltValueEnumConst {
235241
/// the fallback, if available, rather than throwing an exception.
236242
final bool fallback;
237243

238-
const BuiltValueEnumConst(
239-
{this.wireName, this.wireNumber, this.fallback = false});
244+
const BuiltValueEnumConst({
245+
this.wireName,
246+
this.wireNumber,
247+
this.fallback = false,
248+
});
240249
}
241250

242251
/// Optionally, annotate methods with this to cause them to be called by
@@ -275,8 +284,10 @@ class BuiltValueHook {
275284
/// ```
276285
final bool finalizeBuilder;
277286

278-
const BuiltValueHook(
279-
{this.initializeBuilder = false, this.finalizeBuilder = false});
287+
const BuiltValueHook({
288+
this.initializeBuilder = false,
289+
this.finalizeBuilder = false,
290+
});
280291
}
281292

282293
/// Enum Class base class.
@@ -319,7 +330,7 @@ typedef BuiltValueToStringHelperProvider = BuiltValueToStringHelper Function(
319330
/// are [IndentingBuiltValueToStringHelper], which is the default, and
320331
/// [FlatBuiltValueToStringHelper].
321332
BuiltValueToStringHelperProvider newBuiltValueToStringHelper =
322-
(String className) => IndentingBuiltValueToStringHelper(className);
333+
IndentingBuiltValueToStringHelper.new;
323334

324335
/// Interface for built_value toString() output helpers.
325336
///
@@ -422,7 +433,8 @@ class BuiltValueNullFieldError extends Error {
422433

423434
@override
424435
String toString() =>
425-
'Tried to construct class "$type" with null for non-nullable field "$field".';
436+
'Tried to construct class "$type" with null for non-nullable field '
437+
'"$field".';
426438
}
427439

428440
/// [Error] indicating that a built_value class constructor was called with

built_value/lib/iso_8601_date_time_serializer.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// license that can be found in the LICENSE file.
44

55
import 'package:built_collection/built_collection.dart';
6-
import 'package:built_value/serializer.dart';
6+
import 'serializer.dart';
77

88
/// Alternative serializer for [DateTime].
99
///

0 commit comments

Comments
 (0)