Skip to content

Commit 9ea4829

Browse files
committed
fix(*): fix analyze issues
1 parent afdd05f commit 9ea4829

File tree

16 files changed

+85
-2
lines changed

16 files changed

+85
-2
lines changed

lib/extensions/build_context.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ extension AccessContext on BuildContext {
6060
T? readOrNull<T>() {
6161
try {
6262
return read<T>();
63+
// This catch clause intends to be a safe accessor on providers.
64+
// ignore: avoid_catches_without_on_clauses
6365
} catch (e) {
6466
return null;
6567
}

lib/features/checkin/models/checkin_feeling.dart

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,32 @@
11
part of 'models.dart';
22

3-
// ignore_for_file: public_member_api_docs
4-
53
/// All checkin feelings.
64
enum CheckinFeeling {
5+
/// 开心
76
happy,
7+
8+
/// 伤心
89
sad,
10+
11+
/// 郁闷
912
depressed,
13+
14+
/// 无聊
1015
boring,
16+
17+
/// 生气
1118
angry,
19+
20+
/// 无语
1221
speechless,
22+
23+
/// 奋斗
1324
struggle,
25+
26+
/// 慵懒
1427
lazy,
28+
29+
/// 倒霉
1530
unlucky;
1631

1732
factory CheckinFeeling.from(String feeling) {

lib/features/checkin/view/auto_checkin_page.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,24 @@ class _AutoCheckinPageState extends State<AutoCheckinPage> {
5555
),
5656
...succeededList.map(
5757
(e) => AutoCheckinUserCard(
58+
// Ok to use record.
5859
// ignore: avoid_positional_fields_in_records
5960
e.$1,
61+
// Ok to use record.
6062
// ignore: avoid_positional_fields_in_records
6163
CheckinResult.message(context, e.$2),
6264
failure: false,
6365
),
6466
),
6567
...failedList.map(
6668
(e) => AutoCheckinUserCard(
69+
// Ok to use record.
6770
// ignore: avoid_positional_fields_in_records
6871
e.$1,
72+
// Ok to use record.
6973
// ignore: avoid_positional_fields_in_records
7074
CheckinResult.message(context, e.$2),
75+
// Ok to use record.
7176
// ignore: avoid_positional_fields_in_records
7277
failure: e.$2 is! CheckinResultAlreadyChecked,
7378
),

lib/features/editor/widgets/image_dialog.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ class _ImageDialogState extends State<_ImageDialog>
113113
widthController.text = '${uiImage.width}';
114114
heightController.text = '${uiImage.height}';
115115
});
116+
// Intend to catch all exceptions only be aware of a manual required
117+
// state.
118+
// ignore: avoid_catches_without_on_clauses
116119
} catch (e, _) {
117120
// Directly cache Future.error.
118121
error('failed to fill image size: invalid image: $e');

lib/features/homepage/view/homepage_page.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ class _HomepagePageState extends State<HomepagePage> {
223223
username: username,
224224
avatarUrl: avatarUrl,
225225
heroTag: username,
226+
// Ok to use record.
226227
// ignore: avoid_positional_fields_in_records
227228
latestThreadUrl: state.loggedUserInfo
228229
?.relatedLinkPairList.lastOrNull?.$2,

lib/features/settings/repositories/settings_repository.dart

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,26 @@ extension _ExtractExt on List<SettingsEntity> {
2525
return settings.defaultValue;
2626
}
2727
return (switch (T) {
28+
// ref: https://github.com/dart-lang/sdk/issues/59334
29+
// ignore: type_literal_in_constant_pattern
2830
int => v.intValue,
31+
// ref: https://github.com/dart-lang/sdk/issues/59334
32+
// ignore: type_literal_in_constant_pattern
2933
double => v.doubleValue,
34+
// ref: https://github.com/dart-lang/sdk/issues/59334
35+
// ignore: type_literal_in_constant_pattern
3036
String => v.stringValue,
37+
// ref: https://github.com/dart-lang/sdk/issues/59334
38+
// ignore: type_literal_in_constant_pattern
3139
bool => v.boolValue,
40+
// ref: https://github.com/dart-lang/sdk/issues/59334
41+
// ignore: type_literal_in_constant_pattern
3242
DateTime => v.dateTimeValue,
43+
// ref: https://github.com/dart-lang/sdk/issues/59334
44+
// ignore: type_literal_in_constant_pattern
3345
Offset => v.offsetValue,
46+
// ref: https://github.com/dart-lang/sdk/issues/59334
47+
// ignore: type_literal_in_constant_pattern
3448
Size => v.sizeValue,
3549
_ => null,
3650
} ??
@@ -133,12 +147,26 @@ final class SettingsRepository with LoggerMixin {
133147

134148
final name = key.name;
135149
final v = await switch (T) {
150+
// ref: https://github.com/dart-lang/sdk/issues/59334
151+
// ignore: type_literal_in_constant_pattern
136152
int => _storage.getInt(name),
153+
// ref: https://github.com/dart-lang/sdk/issues/59334
154+
// ignore: type_literal_in_constant_pattern
137155
double => _storage.getDouble(name),
156+
// ref: https://github.com/dart-lang/sdk/issues/59334
157+
// ignore: type_literal_in_constant_pattern
138158
String => _storage.getString(name),
159+
// ref: https://github.com/dart-lang/sdk/issues/59334
160+
// ignore: type_literal_in_constant_pattern
139161
bool => _storage.getBool(name),
162+
// ref: https://github.com/dart-lang/sdk/issues/59334
163+
// ignore: type_literal_in_constant_pattern
140164
DateTime => _storage.getDateTime(name),
165+
// ref: https://github.com/dart-lang/sdk/issues/59334
166+
// ignore: type_literal_in_constant_pattern
141167
Offset => _storage.getOffset(name),
168+
// ref: https://github.com/dart-lang/sdk/issues/59334
169+
// ignore: type_literal_in_constant_pattern
142170
Size => _storage.getSize(name),
143171
_ => () {
144172
error('failed to getValue for key $key: unsupported type $T');
@@ -165,12 +193,26 @@ final class SettingsRepository with LoggerMixin {
165193

166194
final name = key.name;
167195
final _ = await switch (T) {
196+
// ref: https://github.com/dart-lang/sdk/issues/59334
197+
// ignore: type_literal_in_constant_pattern
168198
int => _storage.saveInt(name, value as int),
199+
// ref: https://github.com/dart-lang/sdk/issues/59334
200+
// ignore: type_literal_in_constant_pattern
169201
double => _storage.saveDouble(name, value as double),
202+
// ref: https://github.com/dart-lang/sdk/issues/59334
203+
// ignore: type_literal_in_constant_pattern
170204
String => _storage.saveString(name, value as String),
205+
// ref: https://github.com/dart-lang/sdk/issues/59334
206+
// ignore: type_literal_in_constant_pattern
171207
bool => _storage.saveBool(name, value: value as bool),
208+
// ref: https://github.com/dart-lang/sdk/issues/59334
209+
// ignore: type_literal_in_constant_pattern
172210
DateTime => _storage.saveDateTime(name, value as DateTime),
211+
// ref: https://github.com/dart-lang/sdk/issues/59334
212+
// ignore: type_literal_in_constant_pattern
173213
Offset => _storage.saveOffset(name, value as Offset),
214+
// ref: https://github.com/dart-lang/sdk/issues/59334
215+
// ignore: type_literal_in_constant_pattern
174216
Size => _storage.saveSize(name, value as Size),
175217
final t => () {
176218
error('failed to save settings for key $key:'

lib/shared/models/settings.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ enum SettingsKeys<T> implements Comparable<SettingsKeys<T>> {
291291
/// Ignore dynamic generic type here because the function is used to compare
292292
/// all types of [SettingsKeys].
293293
@override
294+
// Intend to have dynamic types.
294295
// ignore: avoid_dynamic
295296
int compareTo(SettingsKeys<dynamic> other) => name.compareTo(other.name);
296297
}

lib/shared/models/settings_map.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// All public fields in the map is defined in settings keys.
12
// ignore_for_file: public_member_api_docs
23

34
part of 'models.dart';

lib/shared/providers/cookie_provider/cookie_provider.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,14 @@ final class CookieProvider with LoggerMixin implements Storage {
181181
///
182182
/// The main difference between web page styles are homepage layout.
183183
///
184+
/// ```console
184185
/// name id avatar forum-info-layout
185186
/// 水晶 4 no avatar <dd> <em> <font>主题</font> <font>123</font> </em> </dd>
186187
/// 爱丽丝 5 avatar <dd> <em>主题</em> , <em>123></em> </dd>
187188
/// 羽翼 6 no avatar Same with style 4
188189
/// 旅行者 13 avatar Same with style 5
189190
/// 自由之翼 12 avatar Same with style 5
191+
/// ```
190192
void _setupWebPageStyle() {}
191193

192194
@override

lib/shared/providers/image_cache_provider/image_cache_provider.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ Future<void> initCache() async {
7171

7272
/// Provider of cached images.
7373
final class ImageCacheProvider with LoggerMixin {
74+
// Can not be const.
7475
// ignore: prefer_const_constructor_declarations
7576
/// Constructor.
7677
ImageCacheProvider(this._netClientProvider);
@@ -380,6 +381,8 @@ final class ImageCacheProvider with LoggerMixin {
380381
// Validate all cached emoji files exists.
381382
final validateResult = info.validateCache(_emojiCacheDirectory.path);
382383
return validateResult;
384+
// Intend to be a muter on all types of exception.
385+
// ignore: avoid_catches_without_on_clauses
383386
} catch (e) {
384387
warning('validate emoji cache failed: invalid emoji info: $e');
385388
return false;
@@ -407,6 +410,8 @@ final class ImageCacheProvider with LoggerMixin {
407410
final info =
408411
EmojiGroupListMapper.fromJson(_emojiCacheInfoFile.readAsStringSync());
409412
return info.emojiGroupList;
413+
// Intend to be a muter on all types of exception.
414+
// ignore: avoid_catches_without_on_clauses
410415
} catch (e) {
411416
warning('failed to load emoji info when decoding json: $e');
412417
return null;

0 commit comments

Comments
 (0)