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
1 change: 1 addition & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ linter:
- unnecessary_brace_in_string_interps
- unnecessary_const
- unnecessary_getters_setters
- unnecessary_late
- unnecessary_library_name
- unnecessary_library_directive
- unnecessary_new
Expand Down
2 changes: 1 addition & 1 deletion app/lib/account/consent_backend.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class ConsentBackend {
final c = await _lookupAndCheck(consentId, user);
final action = _actions[c.kind]!;
final fromAgent = c.fromAgent!;
late String invitingUserEmail;
final String invitingUserEmail;
if (looksLikeUserId(fromAgent)) {
invitingUserEmail = (await accountBackend.getEmailOfUserId(fromAgent))!;
} else {
Expand Down
2 changes: 1 addition & 1 deletion app/lib/account/models.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class User extends db.ExpandoModel<String> {
}

late final isVisible = !isBlocked && !isModerated && !isDeleted;
late final isNotVisible = !isVisible;
bool get isNotVisible => !isVisible;

void updateIsModerated({
required bool isModerated,
Expand Down
2 changes: 1 addition & 1 deletion app/lib/account/session_cookie.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,5 @@ class ClientSessionCookieStatus {
required this.isStrict,
});

late final isPresent = sessionId != null && sessionId!.isNotEmpty;
bool get isPresent => sessionId?.isNotEmpty ?? false;
}
2 changes: 1 addition & 1 deletion app/lib/admin/tools/set_user_blocked.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Future<String> executeSetUserBlocked(List<String> args) async {
final valueAsString = args.length == 2 ? args[1] : null;
final blockedStatus = _parseValue(valueAsString);

late List<User> users;
final List<User> users;
if (isValidEmail(idOrEmail)) {
users = await accountBackend.lookupUsersByEmail(idOrEmail);
} else {
Expand Down
2 changes: 1 addition & 1 deletion app/lib/fake/backend/fake_auth_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ class FakeAuthProvider extends BaseAuthProvider {

@override
Future<AuthResult?> tryAuthenticateAsUser(String input) async {
late String jwtTokenValue;
var accessToken = input;
// TODO: migrate all test to use base64-encoded token
try {
Expand All @@ -110,6 +109,7 @@ class FakeAuthProvider extends BaseAuthProvider {
// ignored
}

final String jwtTokenValue;
if (accessToken.contains('-at-') &&
!JsonWebToken.looksLikeJWT(accessToken)) {
final uri = Uri.tryParse(accessToken);
Expand Down
2 changes: 1 addition & 1 deletion app/lib/fake/backend/fake_pub_worker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Future<void> _fakeAnalysis(Payload payload) async {
total: 20,
);

late Summary summary;
final Summary summary;
if (packageStatus.isObsolete || packageStatus.isLegacy) {
summary = _emptySummary(payload.package, v.version);
dartdocFiles.clear();
Expand Down
6 changes: 2 additions & 4 deletions app/lib/frontend/handlers/misc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Future<shelf.Response> readinessCheckHandler(shelf.Request request) async {

/// Handles requests for /topics
Future<shelf.Response> topicsPageHandler(shelf.Request request) async {
late Map<String, int> topics;
Map<String, int>? topics;
try {
final data = await cache.topicsPageData().get(() async {
return await storageService
Expand All @@ -83,16 +83,14 @@ Future<shelf.Response> topicsPageHandler(shelf.Request request) async {
topics = (utf8JsonDecoder.convert(data!) as Map<String, dynamic>)
.cast<String, int>();
} on FormatException catch (e, st) {
topics = {};
_log.shout('Error loading topics, error:', e, st);
} on DetailedApiRequestError catch (e, st) {
topics = {};
if (e.status != 404) {
_log.severe('Failed to load topics.json, error : ', e, st);
}
}

return htmlResponse(renderTopicsPage(topics));
return htmlResponse(renderTopicsPage(topics ?? {}));
}

/// Handles requests for /robots.txt
Expand Down
2 changes: 1 addition & 1 deletion app/lib/frontend/handlers/package.dart
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ Future<shelf.Response> _handlePackagePage({
}
}
final serviceSw = Stopwatch()..start();
late PackagePageData data;
final PackagePageData data;
try {
data = await loadPackagePageData(package, versionName, assetKind);
} on ModeratedException {
Expand Down
2 changes: 1 addition & 1 deletion app/lib/frontend/request_context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class RequestContext {
clientSessionCookieStatus ?? ClientSessionCookieStatus.missing();

late final _isAuthenticated = sessionData?.isAuthenticated ?? false;
late final isNotAuthenticated = !_isAuthenticated;
bool get isNotAuthenticated => !_isAuthenticated;
late final authenticatedUserId =
_isAuthenticated ? sessionData?.userId : null;
}
Expand Down
4 changes: 2 additions & 2 deletions app/lib/frontend/templates/misc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final _securityMarkdown = _readDocContent('security.md');
/// basename as a key, e.g.:
/// - `help.md` -> (title: 'Help', content: ...)
/// - `help-search.md` -> (title: 'Search', content: ...)
late final _helpArticles = () {
final _helpArticles = () {
final docDir = io.Directory(static_files.resolveDocDirPath());
final files = docDir
.listSync()
Expand All @@ -47,7 +47,7 @@ late final _helpArticles = () {
return results;
}();

late final _sideImage = d.Image.decorative(
final _sideImage = d.Image.decorative(
src: static_files.staticUrls.packagesSideImage,
width: 400,
height: 400,
Expand Down
2 changes: 1 addition & 1 deletion app/lib/package/export_api_to_bucket.dart
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,6 @@ class _BytesAndHash {

_BytesAndHash(this.bytes);

late final length = bytes.length;
int get length => bytes.length;
late final md5Hash = md5.convert(bytes).bytes;
}
2 changes: 1 addition & 1 deletion app/lib/package/model_properties.dart
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class Pubspec {
late final List<Uri> funding = _inner.funding ?? const <Uri>[];

/// Whether the pubspec has any topic entry.
late final hasTopic = canonicalizedTopics.isNotEmpty;
bool get hasTopic => canonicalizedTopics.isNotEmpty;
}

class MinSdkVersion {
Expand Down
2 changes: 1 addition & 1 deletion app/lib/search/mem_index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class InMemoryPackageIndex {
}

List<String>? nameMatches;
late List<PackageHit> packageHits;
List<PackageHit> packageHits;
switch (query.effectiveOrder ?? SearchOrder.top) {
case SearchOrder.top:
if (textResults == null) {
Expand Down
6 changes: 3 additions & 3 deletions app/lib/search/token_index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ class Score {
Score(this._values);
Score.empty() : _values = const <String, double>{};

late final bool isEmpty = _values.isEmpty;
late final bool isNotEmpty = !isEmpty;
bool get isEmpty => _values.isEmpty;
bool get isNotEmpty => !isEmpty;

Set<String> getKeys({bool Function(String key)? where}) =>
_values.keys.where((e) => where == null || where(e)).toSet();
late final double maxValue = _values.values.fold(0.0, math.max);
Map<String, double> getValues() => _values;
bool containsKey(String key) => _values.containsKey(key);
late final int length = _values.length;
int get length => _values.length;

double operator [](String key) => _values[key] ?? 0.0;

Expand Down
2 changes: 1 addition & 1 deletion app/lib/service/entrypoint/search_index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final _logger = Logger('search_index');
Future<void> main(List<String> args, var message) async {
final timer = Timer.periodic(Duration(milliseconds: 250), (_) {});

late ServicesWrapperFn servicesWrapperFn;
final ServicesWrapperFn servicesWrapperFn;
if (envConfig.isRunningInAppengine) {
servicesWrapperFn = withServices;
setupAppEngineLogging();
Expand Down
2 changes: 1 addition & 1 deletion app/lib/service/topics/models.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ part 'models.g.dart';

final _log = Logger('topics');

late final canonicalTopics = () {
final canonicalTopics = () {
try {
final f = File(p.join(resolveAppDir(), '../doc/topics.yaml'));
return CanonicalTopicFileContent.fromYaml(f.readAsStringSync());
Expand Down
2 changes: 1 addition & 1 deletion app/lib/shared/configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ final class Configuration {
late final isFakeOrTest =
projectId == 'dartlang-pub-fake' || projectId == 'dartlang-pub-test';

late final isPublishedEmailNotificationEnabled = true;
bool get isPublishedEmailNotificationEnabled => true;
}

/// Data structure to describe an admin user.
Expand Down
2 changes: 1 addition & 1 deletion pkg/_pub_shared/lib/validation/html/html_validation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void parseAndValidateHtml(String html) {
/// - `<script> tags have no `src` attribute or have content (except `ld+json`
/// meta content).
void validateHtml(Node root) {
late List<Element> Function(String selector) querySelectorAll;
final List<Element> Function(String selector) querySelectorAll;
if (root is DocumentFragment) {
querySelectorAll = root.querySelectorAll;
} else if (root is Document) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/pub_worker/lib/src/bin/pana_wrapper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ Future<void> main(List<String> args) async {
}

final _workerConfigDirectory = Directory('/home/worker/config');
late final _workerConfigPath =
final _workerConfigPath =
_workerConfigDirectory.existsSync() ? _workerConfigDirectory.path : null;
late final _isInsideDocker = _workerConfigPath != null;
final _isInsideDocker = _workerConfigPath != null;
String? _configHomePath(String sdk, String kind) {
if (!_isInsideDocker) {
return null;
Expand Down
2 changes: 1 addition & 1 deletion pkg/web_app/lib/src/widget/completion/widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ final class _CompletionWidget {
return CompletionData.fromJson(root as Map<String, dynamic>);
}

static late final _canvas = HTMLCanvasElement();
static final HTMLCanvasElement _canvas = HTMLCanvasElement();
static int getTextWidth(String text, Element element) {
final ctx = _canvas.context2D;
final style = window.getComputedStyle(element);
Expand Down
Loading