Skip to content

Commit 0c37605

Browse files
committed
More documentation.
1 parent 23d1de9 commit 0c37605

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

app/lib/scorecard/backend.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,15 @@ void registerScoreCardBackend(ScoreCardBackend backend) =>
3030
ScoreCardBackend get scoreCardBackend =>
3131
ss.lookup(#_scorecard_backend) as ScoreCardBackend;
3232

33+
/// Handles the data store and lookup for ScoreCard.
3334
class ScoreCardBackend {
3435
final db.DatastoreDB _db;
3536
ScoreCardBackend(this._db);
3637

38+
/// Returns the [ScoreCardData] for the given package and version.
39+
///
40+
/// When [onlyCurrent] is false, it will try to load earlier versions of the
41+
/// data.
3742
Future<ScoreCardData> getScoreCardData(
3843
String packageName,
3944
String packageVersion, {
@@ -80,6 +85,9 @@ class ScoreCardBackend {
8085
return data;
8186
}
8287

88+
/// Creates or updates a [ScoreCardReport] entry with the report's [data].
89+
/// The [data] will be converted to json and stored as a byte in the report
90+
/// entry.
8391
Future updateReport(
8492
String packageName, String packageVersion, ReportData data) async {
8593
final key = scoreCardKey(packageName, packageVersion)
@@ -109,6 +117,7 @@ class ScoreCardBackend {
109117
});
110118
}
111119

120+
/// Load and deserialize the reports for the given package and version.
112121
Future<Map<String, ReportData>> loadReports(
113122
String packageName, String packageVersion,
114123
{List<String> reportTypes}) async {
@@ -128,6 +137,8 @@ class ScoreCardBackend {
128137
return result;
129138
}
130139

140+
/// Updates the [ScoreCard] entry, reading both the package and version data,
141+
/// alongside the data from reports, and compiles a new summary of them.
131142
Future updateScoreCard(String packageName, String packageVersion) async {
132143
final key = scoreCardKey(packageName, packageVersion);
133144
final pAndPv = await _db.lookup([key.parent, key.parent.parent]);

app/lib/scorecard/models.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ abstract class ReportStatus {
4343
}
4444

4545
/// Summary of various reports for a given PackageVersion.
46+
///
47+
/// The details are pulled in from various data sources, and the entry is
48+
/// recalculated from scratch each time any of the sources change.
4649
@db.Kind(name: 'ScoreCard', idType: db.IdType.String)
4750
class ScoreCard extends db.ExpandoModel {
4851
@db.StringProperty(required: true)
@@ -80,6 +83,7 @@ class ScoreCard extends db.ExpandoModel {
8083
List<String> platformTags;
8184

8285
/// The flags for the package, version or analysis.
86+
/// Example values: entries from [PackageFlags].
8387
@CompatibleStringListProperty()
8488
List<String> flags;
8589

@@ -300,6 +304,7 @@ class PanaReport implements ReportData {
300304
@CompatibleStringListProperty()
301305
List<String> platformTags;
302306

307+
/// The reason pana decided on the [platformTags].
303308
final String platformReason;
304309

305310
final List<PkgDependency> pkgDependencies;

0 commit comments

Comments
 (0)