Skip to content

Commit

Permalink
Update package:lints to v5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
parlough committed Dec 19, 2024
1 parent 5e698cc commit a406ce3
Show file tree
Hide file tree
Showing 32 changed files with 134 additions and 101 deletions.
12 changes: 6 additions & 6 deletions app/lib/admin/backend.dart
Original file line number Diff line number Diff line change
Expand Up @@ -520,10 +520,10 @@ class AdminBackend {
await taskBackend.trackPackage(packageName);
}

/// Handles GET '/api/admin/packages/<package>/assigned-tags'
/// Handles `GET '/api/admin/packages/<package>/assigned-tags'`.
///
/// Note, this API end-point is intentionally locked down even if it doesn't
/// return anything secret. This is because the /admin/ section is only
/// return anything secret. This is because the `/admin/` section is only
/// intended to be exposed to administrators. Users can read the assigned-tags
/// through API that returns list of package tags.
Future<api.AssignedTags> handleGetAssignedTags(
Expand All @@ -541,7 +541,7 @@ class AdminBackend {
);
}

/// Handles POST '/api/admin/packages/<package>/assigned-tags'
/// Handles `POST '/api/admin/packages/<package>/assigned-tags'`.
Future<api.AssignedTags> handlePostAssignedTags(
String packageName,
api.PatchAssignedTags body,
Expand Down Expand Up @@ -586,7 +586,7 @@ class AdminBackend {
});
}

/// Handles GET '/api/admin/packages/<package>/uploaders'
/// Handles `GET '/api/admin/packages/<package>/uploaders'`.
///
/// Returns the list of uploaders for a package.
Future<api.PackageUploaders> handleGetPackageUploaders(
Expand Down Expand Up @@ -620,7 +620,7 @@ class AdminBackend {
.toList();
}

/// Handles PUT '/api/admin/packages/<package>/uploaders/<email>'
/// Handles `PUT '/api/admin/packages/<package>/uploaders/<email>'`.
///
/// Returns the list of uploaders for a package.
Future<api.PackageUploaders> handleAddPackageUploader(
Expand All @@ -645,7 +645,7 @@ class AdminBackend {
return await handleGetPackageUploaders(packageName);
}

/// Handles DELETE '/api/admin/packages/<package>/uploaders/<email>'
/// Handles `DELETE '/api/admin/packages/<package>/uploaders/<email>'`.
///
/// Returns the list of uploaders for a package.
Future<api.PackageUploaders> handleRemovePackageUploader(
Expand Down
21 changes: 12 additions & 9 deletions app/lib/admin/models.dart
Original file line number Diff line number Diff line change
Expand Up @@ -305,20 +305,23 @@ abstract class ModerationViolation {
];
}

/// Describes the parsed structure of a [ModerationCase.subject] (or the same as URL parameter).
/// Describes the parsed structure of a [ModerationCase.subject]
/// (or the same as URL parameter).
class ModerationSubject {
/// The kind of moderation as described by [ModerationSubjectKind], one of:
/// - package,
/// - package-version,
/// - publisher,
/// - user.
///
/// - package
/// - package-version
/// - publisher
/// - user
final String kind;

/// The local name part of the subject, may be a composite, one of:
/// - <package>,
/// - <package>/<version>,
/// - <publisherId>,
/// - <email>.
///
/// - `<package>`
/// - `<package>/<version>`
/// - `<publisherId>`
/// - `<email>`
final String localName;

/// The package name of the subject (if not a publisher, or user).
Expand Down
12 changes: 6 additions & 6 deletions app/lib/frontend/handlers/account.dart
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ Future<shelf.Response> invalidateSessionHandler(shelf.Request request) async {
);
}

/// Handles GET /consent?id=<consentId>
/// Handles `GET /consent?id=<consentId>`.
Future<shelf.Response> consentPageHandler(
shelf.Request request, String? consentId) async {
final unauthenticatedRs = await checkAuthenticatedPageRequest(request);
Expand Down Expand Up @@ -184,7 +184,7 @@ Future<shelf.Response> consentPageHandler(
);
}

/// Handles GET /api/account/options/packages/<package>
/// Handles `GET /api/account/options/packages/<package>`.
Future<AccountPkgOptions> accountPkgOptionsHandler(
shelf.Request request, String package) async {
checkPackageVersionParams(package);
Expand All @@ -210,7 +210,7 @@ Future<LikedPackagesResponse> listPackageLikesHandler(
return LikedPackagesResponse(likedPackages: packageLikes);
}

/// Handles GET /api/account/likes/<package>
/// Handles `GET /api/account/likes/<package>`.
Future<PackageLikeResponse> getLikePackageHandler(
shelf.Request request, String package) async {
checkPackageVersionParams(package);
Expand All @@ -228,7 +228,7 @@ Future<PackageLikeResponse> getLikePackageHandler(
);
}

/// Handles PUT /api/account/likes/<package>
/// Handles `PUT /api/account/likes/<package>`.
Future<PackageLikeResponse> likePackageHandler(
shelf.Request request, String package) async {
final authenticatedUser = await requireAuthenticatedWebUser();
Expand All @@ -237,7 +237,7 @@ Future<PackageLikeResponse> likePackageHandler(
return PackageLikeResponse(liked: true, package: package, created: l.created);
}

/// Handles DELETE /api/account/likes/<package>
/// Handles `DELETE /api/account/likes/<package>`.
Future<shelf.Response> unlikePackageHandler(
shelf.Request request, String package) async {
final authenticatedUser = await requireAuthenticatedWebUser();
Expand All @@ -246,7 +246,7 @@ Future<shelf.Response> unlikePackageHandler(
return shelf.Response(204);
}

/// Handles /api/account/options/publishers/<publisherId>
/// Handles `/api/account/options/publishers/<publisherId>`.
Future<AccountPublisherOptions> accountPublisherOptionsHandler(
shelf.Request request, String publisherId) async {
checkPublisherIdParam(publisherId);
Expand Down
22 changes: 11 additions & 11 deletions app/lib/frontend/handlers/custom_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import '../../task/backend.dart';
import '../../task/models.dart';
import 'cache_control.dart';

/// Handles requests for /api/documentation/<package>
/// Handles requests for `/api/documentation/<package>`.
Future<shelf.Response> apiDocumentationHandler(
shelf.Request request, String package) async {
checkPackageVersionParams(package);
Expand Down Expand Up @@ -113,7 +113,7 @@ Future<shelf.Response> apiPackageNameCompletionDataHandler(
});
}

/// Handles request for /api/packages?page=<num>
/// Handles request for `/api/packages?page=<num>`.
Future<shelf.Response> apiPackagesHandler(shelf.Request request) async {
final int pageSize = 100;
final int page =
Expand Down Expand Up @@ -194,8 +194,7 @@ Future<shelf.Response> apiPackagesHandler(shelf.Request request) async {
return jsonResponse(data!);
}

/// Handles requests for
/// - /api/packages/<package>/metrics
/// Handles requests for `/api/packages/<package>/metrics`.
Future<shelf.Response> apiPackageMetricsHandler(
shelf.Request request, String packageName) async {
final packageVersion = request.requestedUri.queryParameters['version'];
Expand All @@ -211,9 +210,10 @@ Future<shelf.Response> apiPackageMetricsHandler(
return jsonResponse(result);
}

/// Handles requests for
// - /api/packages/<package>/score
/// - /api/packages/<package>/versions/<version>/score
/// Handles requests for:
///
/// - `/api/packages/<package>/score`
/// - `/api/packages/<package>/versions/<version>/score`
Future<VersionScore> packageVersionScoreHandler(
shelf.Request request, String package,
{String? version}) async {
Expand Down Expand Up @@ -471,7 +471,7 @@ Future<shelf.Response> apiSearchHandler(shelf.Request request) async {
return jsonResponse(result, indentJson: requestContext.indentJson);
}

/// Handles GET /api/packages/<package>/options
/// Handles `GET /api/packages/<package>/options`.
Future<PkgOptions> getPackageOptionsHandler(
shelf.Request request,
String package,
Expand All @@ -487,7 +487,7 @@ Future<PkgOptions> getPackageOptionsHandler(
);
}

/// Handles PUT /api/packages/<package>/options
/// Handles `PUT /api/packages/<package>/options`.
Future<PkgOptions> putPackageOptionsHandler(
shelf.Request request,
String package,
Expand All @@ -497,7 +497,7 @@ Future<PkgOptions> putPackageOptionsHandler(
return await getPackageOptionsHandler(request, package);
}

/// Handles GET /api/packages/<package>/versions/<version>/options
/// Handles `GET /api/packages/<package>/versions/<version>/options`.
Future<VersionOptions> getVersionOptionsHandler(
shelf.Request request,
String package,
Expand All @@ -513,7 +513,7 @@ Future<VersionOptions> getVersionOptionsHandler(
);
}

/// Handles PUT /api/packages/<package>/versions/<version>/options
/// Handles `PUT /api/packages/<package>/versions/<version>/options`.
Future<VersionOptions> putVersionOptionsHandler(
shelf.Request request,
String package,
Expand Down
5 changes: 3 additions & 2 deletions app/lib/frontend/handlers/documentation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import '../../shared/handlers.dart';
import '../../shared/urls.dart';

/// Handles requests for:
/// - /documentation/<package>/<version>
///
/// - `/documentation/<package>/<version>`
Future<shelf.Response> documentationHandler(shelf.Request request) async {
final docFilePath = parseRequestUri(request.requestedUri);
if (docFilePath == null) {
Expand Down Expand Up @@ -93,7 +94,7 @@ class DocFilePath {
DocFilePath(this.package, this.version, this.path);
}

/// Parses the /documentation/<package>/<version>/<path with many levels> URL
/// Parses the `/documentation/<package>/<version>/<path with many levels>` URL
/// and returns the parsed structure.
DocFilePath? parseRequestUri(Uri uri) {
final int segmentCount = uri.pathSegments.length;
Expand Down
Loading

0 comments on commit a406ce3

Please sign in to comment.