Skip to content

Commit 432403d

Browse files
committed
Fix all lints and docs
1 parent 68ba21f commit 432403d

Some content is hidden

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

45 files changed

+372
-299
lines changed

.github/workflows/test.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,16 @@ jobs:
2424
lint:
2525
name: Check lints
2626
runs-on: ubuntu-latest
27-
if: ${{ false }}
2827
steps:
2928
- uses: actions/checkout@v3
3029
- name: Setup Flutter
3130
uses: subosito/flutter-action@v2
3231
with:
3332
flutter-version: ${{ secrets.FLUTTER_VERSION }}
34-
- run: flutter pub get
33+
- run: dart pub get
3534
working-directory: packages/isar
3635
- run: flutter pub get
3736
working-directory: packages/isar_flutter_libs
38-
- run: flutter pub get
39-
working-directory: packages/isar_generator
4037
- run: flutter pub get
4138
working-directory: packages/isar_inspector
4239
- run: |

examples/counter/lib/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class _CounterAppState extends State<CounterApp> {
6262
title: 'Isar Counter',
6363
theme: theme,
6464
home: Scaffold(
65-
appBar: AppBar(title: Text('Isar Counter')),
65+
appBar: AppBar(title: const Text('Isar Counter')),
6666
body: Center(
6767
child: Column(
6868
mainAxisAlignment: MainAxisAlignment.center,

examples/counter/pubspec.yaml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,14 @@ environment:
77
dependencies:
88
flutter:
99
sdk: flutter
10-
isar: 4.0.0-dev.4
11-
isar_flutter_libs: ^4.0.0-dev.9
10+
isar: 4.0.0-dev.10
11+
isar_flutter_libs: ^4.0.0-dev.10
1212

1313
dev_dependencies:
1414
build_runner: any
1515
flutter_test:
1616
sdk: flutter
1717
flutter_lints: ^2.0.2
1818

19-
dependency_overrides:
20-
isar:
21-
path: ../../packages/isar
22-
isar_flutter_libs:
23-
path: ../../packages/isar_flutter_libs
24-
2519
flutter:
2620
uses-material-design: true

examples/pub/pubspec.yaml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ dependencies:
1818
sdk: flutter
1919
flutter_riverpod: ^2.3.6
2020
google_fonts: ^5.1.0
21-
isar: 4.0.0-dev.0
22-
isar_flutter_libs: 4.0.0-dev.0
21+
isar: 4.0.0-dev.10
22+
isar_flutter_libs: 4.0.0-dev.10
2323
json_annotation: ^4.8.1
2424
markdown: ^7.1.1
2525
pub_semver: ^2.1.4
@@ -36,12 +36,6 @@ dependencies:
3636
flutter_html_svg: ^3.0.0-beta.2
3737
path_provider: ^2.0.15
3838

39-
dependency_overrides:
40-
isar:
41-
path: ../../packages/isar
42-
isar_flutter_libs:
43-
path: ../../packages/isar_flutter_libs
44-
4539
dev_dependencies:
4640
build_runner: ^2.4.6
4741
copy_with_extension_gen: ^5.0.3

packages/isar/analysis_options.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ analyzer:
99
avoid_positional_boolean_parameters: ignore
1010
parameter_assignments: ignore
1111
use_string_in_part_of_directives: ignore
12+
always_put_required_named_parameters_first: ignore

packages/isar/lib/isar.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/// Extremely fast, easy to use, and fully async NoSQL database for Flutter.
12
library isar;
23

34
import 'dart:async';
@@ -21,7 +22,6 @@ part 'src/annotations/name.dart';
2122
part 'src/annotations/type.dart';
2223
part 'src/annotations/utc.dart';
2324

24-
part 'src/async.dart';
2525
part 'src/compact_condition.dart';
2626

2727
part 'src/impl/filter_builder.dart';

packages/isar/lib/src/async.dart

Lines changed: 0 additions & 29 deletions
This file was deleted.

packages/isar/lib/src/generator/code_gen/query_filter_generator.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ class _FilterGenerator {
6969

7070
String value(String name, PropertyInfo p) {
7171
if (p.enumProperty != null) {
72-
return '$name${p.elementNullable ?? p.nullable ? '?' : ''}.${p.enumProperty}';
72+
final nullable = p.elementNullable ?? p.nullable;
73+
return '$name${nullable ? '?' : ''}.${p.enumProperty}';
7374
} else {
7475
return name;
7576
}

packages/isar/lib/src/generator/helper.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ extension on ClassElement {
1616
final allAccessors = [
1717
...accessors.map((e) => e.variable),
1818
if (collectionAnnotation?.inheritance ?? embeddedAnnotation!.inheritance)
19-
for (InterfaceType supertype in allSupertypes) ...[
19+
for (final supertype in allSupertypes) ...[
2020
if (!supertype.isDartCoreObject)
21-
...supertype.accessors.map((e) => e.variable)
22-
]
21+
...supertype.accessors.map((e) => e.variable),
22+
],
2323
];
2424

2525
final usableAccessors = allAccessors.where(

packages/isar/lib/src/generator/isar_type.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// ignore_for_file: public_member_api_docs
2-
31
part of isar_generator;
42

53
const TypeChecker _dateTimeChecker = TypeChecker.fromRuntime(DateTime);

packages/isar/lib/src/impl/filter_builder.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ Pointer<CIsarValue> _isarValue(Object? value) {
140140
return nullptr;
141141
} else if (value is double) {
142142
return IsarCore.b.isar_value_real(value);
143+
// ignore: avoid_double_and_int_checks
143144
} else if (value is int) {
144145
return IsarCore.b.isar_value_integer(value);
145146
} else if (value is String) {

packages/isar/lib/src/impl/isar_query_impl.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class _IsarQueryImpl<T> extends IsarQuery<T> {
1919
Pointer<CIsarQuery> get _ptr {
2020
final ptr = ptrFromAddress<CIsarQuery>(_ptrAddress);
2121
if (ptr.isNull) {
22-
throw QueryError('Query has already been closed.');
22+
throw StateError('Query has already been closed.');
2323
}
2424
return ptr;
2525
}
@@ -124,7 +124,7 @@ class _IsarQueryImpl<T> extends IsarQuery<T> {
124124
IsarCore.b.isar_read_to_json(reader, bufferPtrPtr, bufferSizePtr);
125125
final bufferPtr = bufferPtrPtr.ptrValue;
126126
if (bufferPtr == nullptr) {
127-
throw QueryError('Error while exporting JSON.');
127+
throw StateError('Error while exporting JSON.');
128128
} else {
129129
final jsonBytes = bufferPtr.asU8List(jsonSize);
130130
return jsonDecode(utf8.decode(jsonBytes)) as Map<String, dynamic>;

packages/isar/lib/src/isar_collection.dart

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,16 @@ abstract class IsarCollection<ID, OBJ> {
2020
/// to 1.
2121
int autoIncrement();
2222

23+
/// {@template collection_get}
2324
/// Get a single object by its [id]. Returns `null` if the object does not
2425
/// exist.
26+
/// {@endtemplate}
2527
OBJ? get(ID id) => getAll([id]).firstOrNull;
2628

29+
/// {@template collection_get_all}
2730
/// Get a list of objects by their [ids]. Objects in the list are `null`
2831
/// if they don't exist.
32+
/// {@endtemplate}
2933
List<OBJ?> getAll(List<ID> ids);
3034

3135
/// Insert or update the [object].
@@ -112,3 +116,16 @@ abstract class IsarCollection<ID, OBJ> {
112116
List<int>? properties,
113117
});
114118
}
119+
120+
/// Asychronous extensions for [IsarCollection].
121+
extension CollectionAsync<ID, OBJ> on IsarCollection<ID, OBJ> {
122+
/// {@macro collection_get}
123+
Future<OBJ?> getAsync(ID id) {
124+
return isar.readAsync((isar) => isar.collection<ID, OBJ>().get(id));
125+
}
126+
127+
/// {@macro collection_get_all}
128+
Future<List<OBJ?>> getAllAsync(List<ID> ids) {
129+
return isar.readAsync((isar) => isar.collection<ID, OBJ>().getAll(ids));
130+
}
131+
}

packages/isar/lib/src/isar_connect.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// ignore_for_file: avoid_print
2+
13
part of isar;
24

35
abstract class _IsarConnect {

packages/isar/lib/src/isar_connect_api.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ class ConnectQueryPayload {
275275
SortProperty(
276276
property: sortProperty!,
277277
sort: sortAsc == true ? Sort.asc : Sort.desc,
278-
)
278+
),
279279
],
280280
);
281281
}

packages/isar/lib/src/isar_core.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
part of isar;
44

5+
/// @nodoc
56
abstract final class IsarCore {
67
static const bool kIsWeb = bool.fromEnvironment('dart.library.js_util');
78

@@ -238,6 +239,7 @@ abstract final class IsarCore {
238239
}
239240
}
240241

242+
/// @nodoc
241243
extension PointerX on Pointer<void> {
242244
@tryInline
243245
bool get isNull => address == 0;

packages/isar/lib/src/isar_error.dart

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
part of isar;
22

3+
/// Superclass of all Isar errors.
34
sealed class IsarError extends Error {
5+
/// Name of the error.
46
String get name;
57

8+
/// Error message.
69
String get message;
710

811
@override
@@ -11,6 +14,7 @@ sealed class IsarError extends Error {
1114
}
1215
}
1316

17+
/// Invalid or protected path error.
1418
class PathError extends IsarError {
1519
@override
1620
final name = 'PathError';
@@ -20,6 +24,7 @@ class PathError extends IsarError {
2024
'for example because it is a file.';
2125
}
2226

27+
/// An active write transaction is required for this operation.
2328
class WriteTxnRequiredError extends IsarError {
2429
@override
2530
String get name => 'WriteTxnRequiredError';
@@ -28,6 +33,7 @@ class WriteTxnRequiredError extends IsarError {
2833
String get message => 'This operation requires an active write transaction.';
2934
}
3035

36+
/// Database file is incompatible with this version of Isar.
3137
class VersionError extends IsarError {
3238
@override
3339
String get name => 'VersionError';
@@ -37,6 +43,7 @@ class VersionError extends IsarError {
3743
'version of Isar. Please check if you need to migrate the database.';
3844
}
3945

46+
/// The object is too large to be stored in Isar.
4047
class ObjectLimitReachedError extends IsarError {
4148
@override
4249
String get name => 'ObjectLimitReachedError';
@@ -47,6 +54,7 @@ class ObjectLimitReachedError extends IsarError {
4754
'than 16MB.';
4855
}
4956

57+
/// Invalid Isar instance.
5058
class InstanceMismatchError extends IsarError {
5159
@override
5260
String get name => 'InstanceMismatchError';
@@ -57,6 +65,8 @@ class InstanceMismatchError extends IsarError {
5765
'from a different Isar instance.';
5866
}
5967

68+
/// Something went wrong during encryption/decryption. Most likely the
69+
/// encryption key is wrong.
6070
class EncryptionError extends IsarError {
6171
@override
6272
String get name => 'EncryptionError';
@@ -67,6 +77,7 @@ class EncryptionError extends IsarError {
6777
'corrupted.';
6878
}
6979

80+
/// The database is full.
7081
class DatabaseFullError extends IsarError {
7182
@override
7283
final name = 'DatabaseFullError';
@@ -78,6 +89,7 @@ class DatabaseFullError extends IsarError {
7889
'specifying a CompactCondition when opening Isar.';
7990
}
8091

92+
/// Isar has not been initialized correctly.
8193
class IsarNotReadyError extends IsarError {
8294
/// @nodoc
8395
@protected
@@ -90,18 +102,7 @@ class IsarNotReadyError extends IsarError {
90102
final String message;
91103
}
92104

93-
class QueryError extends IsarError {
94-
/// @nodoc
95-
@protected
96-
QueryError(this.message);
97-
98-
@override
99-
String get name => 'QueryError';
100-
101-
@override
102-
final String message;
103-
}
104-
105+
/// Unknown error returned by the database engine.
105106
class DatabaseError extends IsarError {
106107
/// @nodoc
107108
@protected

0 commit comments

Comments
 (0)