Skip to content

Commit e83479a

Browse files
authored
Fixes to health (#363)
1 parent 552f534 commit e83479a

File tree

6 files changed

+53
-18
lines changed

6 files changed

+53
-18
lines changed

pkgs/firehose/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.11.0
2+
3+
- Bump dart_apitool which can now report leak locations.
4+
15
## 0.10.5
26

37
- Bump dart_apitool to work with non-published dev dependencies.

pkgs/firehose/lib/src/health/health.dart

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ ${changeForPackage.entries.map((e) => '|${e.key.name}|${e.value.toMarkdownRow()}
262262

263263
Future<HealthCheckResult> leakingCheck() async {
264264
var filesInPR = await listFilesInPRorAll();
265-
final leaksForPackage = <Package, List<String>>{};
265+
final leaksInPackages = <(Package, Leak)>[];
266266

267267
final flutterPackages =
268268
packagesContaining(filesInPR, only: flutterPackageGlobs);
@@ -310,7 +310,10 @@ ${changeForPackage.entries.map((e) => '|${e.key.name}|${e.value.toMarkdownRow()}
310310
var leaks = decoded['missingEntryPoints'] as List<dynamic>;
311311

312312
if (leaks.isNotEmpty) {
313-
leaksForPackage[package] = leaks.cast();
313+
leaksInPackages.addAll(leaks.map(
314+
(leakJson) =>
315+
(package, Leak.fromJson(leakJson as Map<String, dynamic>)),
316+
));
314317

315318
final desc = leaks.map((item) => '$item').join(', ');
316319
log('Leaked symbols found: $desc.');
@@ -334,15 +337,13 @@ ${changeForPackage.entries.map((e) => '|${e.key.name}|${e.value.toMarkdownRow()}
334337
}
335338
return HealthCheckResult(
336339
Check.leaking,
337-
leaksForPackage.values.any((leaks) => leaks.isNotEmpty)
338-
? Severity.warning
339-
: Severity.success,
340+
leaksInPackages.isNotEmpty ? Severity.warning : Severity.success,
340341
'''
341342
The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.
342343
343-
| Package | Leaked API symbols |
344-
| :--- | :--- |
345-
${leaksForPackage.entries.map((e) => '|${e.key.name}|${e.value.join('<br>')}|').join('\n')}
344+
| Package | Leaked API symbol | Leaking sources |
345+
| :--- | :--- | :--- |
346+
${leaksInPackages.map((e) => '|${e.$1.name}|${e.$2.name}|${e.$2.usages.join('<br>')}|').join('\n')}
346347
''',
347348
);
348349
}
@@ -548,6 +549,30 @@ ${isWorseThanInfo ? 'This check can be disabled by tagging the PR with `skip-${r
548549
}
549550
}
550551

552+
class Leak {
553+
/// The type of the leak, e.g., 'interface'.
554+
final String type;
555+
556+
/// A list of strings representing where the leak is used.
557+
final List<String> usages;
558+
559+
final String name;
560+
561+
Leak._({
562+
required this.type,
563+
required this.usages,
564+
required this.name,
565+
});
566+
567+
factory Leak.fromJson(Map<String, dynamic> json) {
568+
return Leak._(
569+
type: json['type'] as String,
570+
usages: (json['usages'] as List<dynamic>).cast<String>(),
571+
name: json['name'] as String,
572+
);
573+
}
574+
}
575+
551576
enum BreakingLevel {
552577
none('None'),
553578
nonBreaking('Non-Breaking'),

pkgs/firehose/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: firehose
22
description: A tool to automate publishing of Pub packages from GitHub actions.
3-
version: 0.10.5
3+
version: 0.11.0
44
repository: https://github.com/dart-lang/ecosystem/tree/main/pkgs/firehose
55

66
environment:

pkgs/firehose/test_data/golden/comment_leaking.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55

66
The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.
77

8-
| Package | Leaked API symbols |
9-
| :--- | :--- |
10-
|package5|NonExported<br>NonExported2<br>TransitiveNonExported|
8+
| Package | Leaked API symbol | Leaking sources |
9+
| :--- | :--- | :--- |
10+
|package5|NonExported|package5_base.dart::Awesome::myClass|
11+
|package5|NonExported2|package5_base.dart::Awesome::myClass2|
12+
|package5|TransitiveNonExported|package5_base.dart::NonExported2::myClass|
1113

1214

1315
This check can be disabled by tagging the PR with `skip-leaking-check`.

pkgs/firehose/test_data/golden/comment_leaking_healthchanged.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55

66
The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.
77

8-
| Package | Leaked API symbols |
9-
| :--- | :--- |
10-
|package5|NonExported<br>NonExported2<br>TransitiveNonExported|
8+
| Package | Leaked API symbol | Leaking sources |
9+
| :--- | :--- | :--- |
10+
|package5|NonExported|package5_base.dart::Awesome::myClass|
11+
|package5|NonExported2|package5_base.dart::Awesome::myClass2|
12+
|package5|TransitiveNonExported|package5_base.dart::NonExported2::myClass|
1113

1214

1315
This check can be disabled by tagging the PR with `skip-leaking-check`.

pkgs/firehose/test_data/golden/comment_leaking_ignore_package.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55

66
The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.
77

8-
| Package | Leaked API symbols |
9-
| :--- | :--- |
10-
|package5|NonExported<br>NonExported2<br>TransitiveNonExported|
8+
| Package | Leaked API symbol | Leaking sources |
9+
| :--- | :--- | :--- |
10+
|package5|NonExported|package5_base.dart::Awesome::myClass|
11+
|package5|NonExported2|package5_base.dart::Awesome::myClass2|
12+
|package5|TransitiveNonExported|package5_base.dart::NonExported2::myClass|
1113

1214

1315
This check can be disabled by tagging the PR with `skip-leaking-check`.

0 commit comments

Comments
 (0)