Skip to content

Commit

Permalink
lint: update flutter_lints pkg to v3.0.1 and fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
sliverappbar committed Nov 12, 2023
1 parent 46a075e commit 2a631da
Show file tree
Hide file tree
Showing 134 changed files with 528 additions and 602 deletions.
1 change: 0 additions & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ linter:
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
avoid_function_literals_in_foreach_calls: false # TODO(ykh09242): Enable this lint.
avoid_print: false
use_build_context_synchronously: false # TODO(ykh09242): Enable this lint.

Expand Down
2 changes: 1 addition & 1 deletion lib/cert/root.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:violet/cert/cert_data.dart';
import 'package:violet/cert/cert_util.dart';

class RootCert extends CertData {
RootCert({required Map<String, dynamic> data}) : super(data: data);
RootCert({required super.data});

RSAPublicKey rsaPublic() => CertUtil.importRSAPublicKey(data['PubKey']);

Expand Down
8 changes: 4 additions & 4 deletions lib/component/eh/eh_bookmark.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class EHBookmark {
'https://exhentai.org/favorites.php?page=$j&favcat=$i');
var matched = rr.allMatches(html).map((e) => e.group(0));
if (matched.isEmpty) break;
matched.forEach((element) {
for (var element in matched) {
hh.add(int.parse(element!.split('/')[4]));
});
}
}
} catch (_) {}
result.add(hh);
Expand All @@ -39,9 +39,9 @@ class EHBookmark {
'https://e-hentai.org/favorites.php?page=$j&favcat=$i');
var matched = r2.allMatches(html).map((e) => e.group(0));
if (matched.isEmpty) break;
matched.forEach((element) {
for (var element in matched) {
result[i].add(int.parse(element!.split('/')[4]));
});
}
}
} catch (_) {}
}
Expand Down
20 changes: 10 additions & 10 deletions lib/component/eh/eh_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class EHParser {
doc.querySelectorAll("div[id='gmid'] div[id='taglist'] table tr");
var info = <String, List<String>>{};

nodesData.forEach((element) {
for (var element in nodesData) {
try {
info[element.querySelector('td')!.text.trim()] = element
.querySelectorAll('td')[1]
Expand All @@ -146,7 +146,7 @@ class EHParser {
Logger.error('[eh-parser] E: $e\n'
'$st');
}
});
}

if (info.containsKey('language:')) article.languages = info['language:'];
if (info.containsKey('group:')) article.group = info['group:'];
Expand All @@ -162,7 +162,7 @@ class EHParser {

var hu = HtmlUnescape();
var df = DateFormat('dd MMMM yyyy, H:m');
nodeComments.forEach((element) {
for (var element in nodeComments) {
var date =
hu.convert(element.querySelector('div.c2 div.c3')!.text.trim());
var author =
Expand All @@ -179,7 +179,7 @@ class EHParser {
true),
author,
contents));
});
}

comments.sort((x, y) => x.item1.compareTo(y.item1));
article.comment = comments;
Expand All @@ -193,7 +193,7 @@ class EHParser {

var nodes = parse(html).querySelectorAll('div.itg > div.id1');

nodes.forEach((element) {
for (var element in nodes) {
try {
var article = EHResultArticle();

Expand All @@ -210,7 +210,7 @@ class EHParser {

result.add(article);
} catch (_) {}
});
}

return result;
}
Expand All @@ -223,7 +223,7 @@ class EHParser {

if (nodes.length > 1) nodes.removeAt(0);

nodes.forEach((element) {
for (var element in nodes) {
try {
var article = EHResultArticle();
var tds = element.querySelectorAll('td');
Expand All @@ -242,7 +242,7 @@ class EHParser {

result.add(article);
} catch (_) {}
});
}

return result;
}
Expand Down Expand Up @@ -325,7 +325,7 @@ class EHParser {

if (nodes.length > 1) nodes.removeAt(0);

nodes.forEach((element) {
for (var element in nodes) {
var article = EHResultArticle();

article.type =
Expand Down Expand Up @@ -365,7 +365,7 @@ class EHParser {
element.querySelectorAll('td')[5].querySelector('div a')!.text.trim();

result.add(article);
});
}

return result;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/component/hitomi/indexs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ class HitomiIndexs {
'assets/locale/tag/related-tag-${TagTranslate.defaultLanguage}.json'))
as List<dynamic>;
relatedTag = <String, dynamic>{};
relatedData.forEach((element) {
for (var element in relatedData) {
var kv = (element as Map<String, dynamic>).entries.first;
relatedTag[kv.key] = kv.value;
});
}
}

static List<Tuple2<String, double>> _calculateSimilars(
Expand Down
8 changes: 4 additions & 4 deletions lib/component/hitomi/series_finder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ class SeriesFinder {
}

seriesList.sort((x, y) => x.length.compareTo(y.length));
seriesList.forEach((element) {
for (var element in seriesList) {
print('[${element.length}] ${element.first.artists()}');
});
}
}

static Future<void> doFind2() async {
Expand Down Expand Up @@ -150,8 +150,8 @@ class SeriesFinder {
}

seriesList.sort((x, y) => x.item2.length.compareTo(y.item2.length));
seriesList.forEach((element) {
for (var element in seriesList) {
print('[${element.item2.length}] ${element.item1}');
});
}
}
}
12 changes: 6 additions & 6 deletions lib/component/hitomi/tag_translate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ class TagTranslate {
var result = contains(part) + containsAndro(part);
var overlap = <String>{};
var rresult = <DisplayedTag>[];
result.forEach((element) {
if (overlap.contains(element.getTag())) return;
for (var element in result) {
if (overlap.contains(element.getTag())) continue;
overlap.add(element.getTag());
rresult.add(element);
});
}
return rresult;
}

Expand Down Expand Up @@ -167,11 +167,11 @@ class TagTranslate {
result.sort((x, y) => x.item2.compareTo(y.item2));
var overlap = <String>{};
var rresult = <Tuple2<DisplayedTag, int>>[];
result.forEach((element) {
if (overlap.contains(element.item1.getTag())) return;
for (var element in result) {
if (overlap.contains(element.item1.getTag())) continue;
overlap.add(element.item1.getTag());
rresult.add(element);
});
}
return rresult;
}

Expand Down
14 changes: 7 additions & 7 deletions lib/component/hitomi/title_cluster.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,28 +64,28 @@ class HitomiTitleCluster {
if (maxnode > 100) maxnode = 100;

var groups = <List<int>>[];
ctitles.forEach((element) {
for (var element in ctitles) {
var near = tree.nearest(element, maxnode, 8);

var rr = <int>[];
near.forEach((element) {
for (var element in near) {
rr.add(element[0]['t'].index);
});
}

rr.sort();
groups.add(rr);
});
}

// Group By Same Lists
var gg = groupBy(groups, (group) => group.join(','));
var ds = DisjointSet(titles.length);

// Join groups
gg.forEach((key, value) {
value[0].forEach((element) {
if (value[0][0] == element) return;
for (var element in value[0]) {
if (value[0][0] == element) continue;
ds.union(value[0][0], element);
});
}
});

var join = <int, List<int>>{};
Expand Down
4 changes: 2 additions & 2 deletions lib/database/query.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ class QueryManager {
queryRaw + (!Settings.searchPure ? ' AND ExistOnHitomi=1' : ''));

var qr = <String, QueryResult>{};
qm.results!.forEach((element) {
for (var element in qm.results!) {
qr[element.id().toString()] = element;
});
}

var rr = ids
.where((e) => qr.containsKey(e.toString()))
Expand Down
24 changes: 12 additions & 12 deletions lib/database/user/bookmark.dart
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,9 @@ class Bookmark {
groups[y] = tmp;
}

groups.forEach((element) {
for (var element in groups) {
print(element.gorder());
});
}

if (from < to) {
for (; from < to; from++) {
Expand All @@ -306,9 +306,9 @@ class Bookmark {
}
}

groups.forEach((element) {
for (var element in groups) {
print(element.gorder());
});
}
}

Future<List<BookmarkArticle>> getArticle() async {
Expand Down Expand Up @@ -354,9 +354,9 @@ class Bookmark {
if (bookmarkSet == null) {
var article = await getArticle();
bookmarkSet = HashSet<int>();
article.forEach((element) {
for (var element in article) {
bookmarkSet!.add(int.parse(element.article()));
});
}
}

return bookmarkSet!.contains(id);
Expand Down Expand Up @@ -385,9 +385,9 @@ class Bookmark {
bookmarkArtistSet![2] = HashSet<String>();
bookmarkArtistSet![3] = HashSet<String>();
bookmarkArtistSet![4] = HashSet<String>();
artist.forEach((element) {
for (var element in artist) {
bookmarkArtistSet![element.type()]!.add(element.artist());
});
}
}

return bookmarkArtistSet![type]!.contains(name);
Expand All @@ -398,9 +398,9 @@ class Bookmark {
if (bookmarkUserSet == null) {
var user = await getUser();
bookmarkUserSet = HashSet<String>();
user.forEach((element) {
for (var element in user) {
bookmarkUserSet!.add(element.user());
});
}
}

return bookmarkUserSet!.contains(user);
Expand All @@ -411,9 +411,9 @@ class Bookmark {
if (historyUserSet == null) {
var user = await getHistoryUser();
historyUserSet = HashSet<String>();
user.forEach((element) {
for (var element in user) {
historyUserSet!.add(element.user());
});
}
}

return historyUserSet!.contains(user);
Expand Down
8 changes: 5 additions & 3 deletions lib/downloader/isolate/core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ class IsolateDownloaderTask {
if (task.accept != null) header['accept'] = task.accept!;
if (task.userAgent != null) header['user-agent'] = task.userAgent!;
if (task.headers != null) {
task.headers!.entries.forEach((element) {
for (var element in task.headers!.entries) {
header[element.key.toLowerCase()] = element.value;
});
}
}
return IsolateDownloaderTask(
id: taskId,
Expand Down Expand Up @@ -282,7 +282,9 @@ void _cancelTask(int taskId) {
/// cancel all tasks and remove dqueue
void _terminate() {
_dqueue.clear();
_workingMap.entries.forEach((element) => element.value.cancelToken!.cancel());
for (var value in _workingMap.values) {
value.cancelToken!.cancel();
}
}

void _modifyTaskPoolSize(int sz) {
Expand Down
4 changes: 2 additions & 2 deletions lib/log/log.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ class Logger {
}

static Future<void> showLogs() async {
(await logFile.readAsLines()).forEach((element) {
for (var element in (await logFile.readAsLines())) {
print(element);
});
}
}

static Future<void> exportLog() async {
Expand Down
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Future<void> initFirebase() async {
}

class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
const MyApp({super.key});

@override
Widget build(BuildContext context) {
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/after_loading/afterloading_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import 'package:violet/version/update_sync.dart';
import 'package:violet/widgets/toast.dart';

class AfterLoadingPage extends StatefulWidget {
const AfterLoadingPage({Key? key}) : super(key: key);
const AfterLoadingPage({super.key});

@override
State<AfterLoadingPage> createState() => AfterLoadingPageState();
Expand Down
Loading

0 comments on commit 2a631da

Please sign in to comment.