Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/lib/admin/tools/delete_all_staging.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Future<void> _batchedQuery<T extends Model>(

void flush() {
if (keys.isEmpty) return;
fn(List.from(keys));
fn(List.of(keys));
keys.clear();
budget = _defaultBudget;
}
Expand Down
7 changes: 4 additions & 3 deletions app/lib/frontend/handlers/account.dart
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,10 @@ Future<LikedPackagesResponse> listPackageLikesHandler(
final authenticatedUser = await requireAuthenticatedWebUser();
final user = authenticatedUser.user;
final packages = await likeBackend.listPackageLikes(user);
final List<PackageLikeResponse> packageLikes = List.from(packages.map(
(like) => PackageLikeResponse(
liked: true, package: like.package, created: like.created)));
final List<PackageLikeResponse> packageLikes = packages
.map((like) => PackageLikeResponse(
liked: true, package: like.package, created: like.created))
.toList();
return LikedPackagesResponse(likedPackages: packageLikes);
}

Expand Down
3 changes: 1 addition & 2 deletions app/lib/frontend/handlers/custom_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,7 @@ Future<shelf.Response> apiSearchHandler(shelf.Request request) async {
if (sr.errorMessage != null) 'message': sr.errorMessage,
};
if (hasNextPage) {
final newParams =
Map<String, dynamic>.from(request.requestedUri.queryParameters);
final newParams = {...request.requestedUri.queryParameters};
newParams['page'] = (searchForm.currentPage! + 1).toString();
final nextPageUrl =
request.requestedUri.replace(queryParameters: newParams).toString();
Expand Down
5 changes: 2 additions & 3 deletions app/lib/frontend/static_files.dart
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ class StaticFileCache {
String get etag => _etag ??= _calculateEtagOfEtags().substring(0, 8);

String _calculateEtagOfEtags() {
final files = List<StaticFile>.from(_files.values);
final files = _files.values.toList();
files.sort((a, b) => a.requestPath.compareTo(b.requestPath));
final concatenatedEtags = files.map((f) => f.etag).join(' ');
final digest = crypto.sha256.convert(utf8.encode(concatenatedEtags));
Expand Down Expand Up @@ -402,8 +402,7 @@ class ParsedStaticUrl {

factory ParsedStaticUrl.parse(Uri requestedUri) {
final normalizedRequestPath = path.normalize(requestedUri.path);
final pathSegments =
List<String>.from(Uri(path: normalizedRequestPath).pathSegments);
final pathSegments = List.of(Uri(path: normalizedRequestPath).pathSegments);
String? pathHash;
var filePath = normalizedRequestPath;
if (pathSegments.length > 2 && pathSegments[1].startsWith('hash-')) {
Expand Down
4 changes: 2 additions & 2 deletions app/lib/search/models.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.

import 'package:clock/clock.dart';
import 'package:collection/collection.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:pub_dev/shared/popularity_storage.dart';

Expand Down Expand Up @@ -59,8 +60,7 @@ extension UpdateLikesExt on Iterable<PackageDocument> {
/// The score is normalized into the range of [0.0 - 1.0] using the
/// ordered list of packages by like counts (same like count gets the same score).
void updateLikeScores() {
final sortedByLikes = List<PackageDocument>.from(this)
..sort((a, b) => a.likeCount.compareTo(b.likeCount));
final sortedByLikes = sorted((a, b) => a.likeCount.compareTo(b.likeCount));
for (var i = 0; i < sortedByLikes.length; i++) {
if (i > 0 &&
sortedByLikes[i - 1].likeCount == sortedByLikes[i].likeCount) {
Expand Down
2 changes: 1 addition & 1 deletion app/lib/search/search_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class PackageDocument {
Map<String, dynamic> toJson() => _$PackageDocumentToJson(this);

@JsonKey(includeFromJson: false, includeToJson: false)
late final tagsForLookup = Set<String>.from(tags);
late final Set<String> tagsForLookup = Set.of(tags);
}

/// A reference to an API doc page
Expand Down
2 changes: 1 addition & 1 deletion app/lib/service/youtube/backend.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class YoutubeBackend {
/// Algorithm description at [YoutubeBackend.getTopPackageOfWeekVideos].
@visibleForTesting
List<T> selectRandomVideos<T>(math.Random random, List<T> source, int count) {
final selectable = List<T>.from(source);
final selectable = List.of(source);
final selected = <T>[];
while (selected.length < count && selectable.isNotEmpty) {
if (selected.isEmpty) {
Expand Down
3 changes: 1 addition & 2 deletions app/lib/shared/configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import 'dart:convert' show json;
import 'dart:io';

import 'package:collection/collection.dart' show UnmodifiableSetView;
import 'package:gcloud/service_scope.dart' as ss;
import 'package:json_annotation/json_annotation.dart';
import 'package:meta/meta.dart';
Expand Down Expand Up @@ -455,7 +454,7 @@ class AdminId {
required this.oauthUserId,
required this.email,
required Iterable<AdminPermission?> permissions,
}) : permissions = UnmodifiableSetView(Set.from(permissions));
}) : permissions = Set.unmodifiable(permissions.nonNulls);

factory AdminId.fromJson(Map<String, dynamic> json) =>
_$AdminIdFromJson(json);
Expand Down
2 changes: 1 addition & 1 deletion app/lib/shared/markdown.dart
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ String _rewriteAbsoluteUrl(String url) {
if (uri.host == 'github.com') {
final segments = uri.pathSegments;
if (segments.length > 3 && segments[2] == 'blob') {
final newSegments = List<String>.from(segments);
final newSegments = List.of(segments);
newSegments[2] = 'raw';
return uri.replace(pathSegments: newSegments).toString();
}
Expand Down
2 changes: 1 addition & 1 deletion app/lib/shared/urls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ String? getRepositoryUrl(
}
try {
final uri = Uri.parse(repository!);
final segments = List<String>.from(uri.pathSegments);
final segments = List.of(uri.pathSegments);
while (segments.isNotEmpty && segments.last.isEmpty) {
segments.removeLast();
}
Expand Down
2 changes: 1 addition & 1 deletion app/lib/shared/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class LastNTracker<T extends Comparable<T>> {

T? _getP(double p) {
if (_lastItems.isEmpty) return null;
final List<T> list = List.from(_lastItems);
final List<T> list = _lastItems.toList();
list.sort();
return list[(list.length * p).floor()];
}
Expand Down
2 changes: 1 addition & 1 deletion app/lib/task/cloudcompute/googlecloudcompute.dart
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ class _GoogleCloudCompute extends CloudCompute {
);

@override
List<String> get zones => List.from(_zones);
List<String> get zones => List.of(_zones);

@override
String generateInstanceName() => 'worker-${Ulid()}';
Expand Down
2 changes: 1 addition & 1 deletion pkg/fake_gcloud/lib/mem_datastore.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class MemDatastore implements Datastore {
Future<List<Key>> allocateIds(List<Key> keys) async {
return keys.map((k) {
if (k.elements.last.id == null) {
final elements = List<KeyElement>.from(k.elements);
final elements = List.of(k.elements);
final last = elements.removeLast();
elements.add(KeyElement(last.kind, _unusedId++));
return Key(elements, partition: k.partition);
Expand Down
Loading