Fixes to health (#363)
diff --git a/pkgs/firehose/CHANGELOG.md b/pkgs/firehose/CHANGELOG.md
index 8ef8477..b5ee508 100644
--- a/pkgs/firehose/CHANGELOG.md
+++ b/pkgs/firehose/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.11.0
+
+- Bump dart_apitool which can now report leak locations.
+
## 0.10.5
- Bump dart_apitool to work with non-published dev dependencies.
diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart
index a913054..c1d2867 100644
--- a/pkgs/firehose/lib/src/health/health.dart
+++ b/pkgs/firehose/lib/src/health/health.dart
@@ -262,7 +262,7 @@
Future<HealthCheckResult> leakingCheck() async {
var filesInPR = await listFilesInPRorAll();
- final leaksForPackage = <Package, List<String>>{};
+ final leaksInPackages = <(Package, Leak)>[];
final flutterPackages =
packagesContaining(filesInPR, only: flutterPackageGlobs);
@@ -310,7 +310,10 @@
var leaks = decoded['missingEntryPoints'] as List<dynamic>;
if (leaks.isNotEmpty) {
- leaksForPackage[package] = leaks.cast();
+ leaksInPackages.addAll(leaks.map(
+ (leakJson) =>
+ (package, Leak.fromJson(leakJson as Map<String, dynamic>)),
+ ));
final desc = leaks.map((item) => '$item').join(', ');
log('Leaked symbols found: $desc.');
@@ -334,15 +337,13 @@
}
return HealthCheckResult(
Check.leaking,
- leaksForPackage.values.any((leaks) => leaks.isNotEmpty)
- ? Severity.warning
- : Severity.success,
+ leaksInPackages.isNotEmpty ? Severity.warning : Severity.success,
'''
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.
-| Package | Leaked API symbols |
-| :--- | :--- |
-${leaksForPackage.entries.map((e) => '|${e.key.name}|${e.value.join('<br>')}|').join('\n')}
+| Package | Leaked API symbol | Leaking sources |
+| :--- | :--- | :--- |
+${leaksInPackages.map((e) => '|${e.$1.name}|${e.$2.name}|${e.$2.usages.join('<br>')}|').join('\n')}
''',
);
}
@@ -548,6 +549,30 @@
}
}
+class Leak {
+ /// The type of the leak, e.g., 'interface'.
+ final String type;
+
+ /// A list of strings representing where the leak is used.
+ final List<String> usages;
+
+ final String name;
+
+ Leak._({
+ required this.type,
+ required this.usages,
+ required this.name,
+ });
+
+ factory Leak.fromJson(Map<String, dynamic> json) {
+ return Leak._(
+ type: json['type'] as String,
+ usages: (json['usages'] as List<dynamic>).cast<String>(),
+ name: json['name'] as String,
+ );
+ }
+}
+
enum BreakingLevel {
none('None'),
nonBreaking('Non-Breaking'),
diff --git a/pkgs/firehose/pubspec.yaml b/pkgs/firehose/pubspec.yaml
index 949a88f..c56ac76 100644
--- a/pkgs/firehose/pubspec.yaml
+++ b/pkgs/firehose/pubspec.yaml
@@ -1,6 +1,6 @@
name: firehose
description: A tool to automate publishing of Pub packages from GitHub actions.
-version: 0.10.5
+version: 0.11.0
repository: https://github.com/dart-lang/ecosystem/tree/main/pkgs/firehose
environment:
diff --git a/pkgs/firehose/test_data/golden/comment_leaking.md b/pkgs/firehose/test_data/golden/comment_leaking.md
index b0abc3d..4711c9c 100644
--- a/pkgs/firehose/test_data/golden/comment_leaking.md
+++ b/pkgs/firehose/test_data/golden/comment_leaking.md
@@ -5,9 +5,11 @@
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.
-| Package | Leaked API symbols |
-| :--- | :--- |
-|package5|NonExported<br>NonExported2<br>TransitiveNonExported|
+| Package | Leaked API symbol | Leaking sources |
+| :--- | :--- | :--- |
+|package5|NonExported|package5_base.dart::Awesome::myClass|
+|package5|NonExported2|package5_base.dart::Awesome::myClass2|
+|package5|TransitiveNonExported|package5_base.dart::NonExported2::myClass|
This check can be disabled by tagging the PR with `skip-leaking-check`.
diff --git a/pkgs/firehose/test_data/golden/comment_leaking_healthchanged.md b/pkgs/firehose/test_data/golden/comment_leaking_healthchanged.md
index b0abc3d..4711c9c 100644
--- a/pkgs/firehose/test_data/golden/comment_leaking_healthchanged.md
+++ b/pkgs/firehose/test_data/golden/comment_leaking_healthchanged.md
@@ -5,9 +5,11 @@
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.
-| Package | Leaked API symbols |
-| :--- | :--- |
-|package5|NonExported<br>NonExported2<br>TransitiveNonExported|
+| Package | Leaked API symbol | Leaking sources |
+| :--- | :--- | :--- |
+|package5|NonExported|package5_base.dart::Awesome::myClass|
+|package5|NonExported2|package5_base.dart::Awesome::myClass2|
+|package5|TransitiveNonExported|package5_base.dart::NonExported2::myClass|
This check can be disabled by tagging the PR with `skip-leaking-check`.
diff --git a/pkgs/firehose/test_data/golden/comment_leaking_ignore_package.md b/pkgs/firehose/test_data/golden/comment_leaking_ignore_package.md
index b0abc3d..4711c9c 100644
--- a/pkgs/firehose/test_data/golden/comment_leaking_ignore_package.md
+++ b/pkgs/firehose/test_data/golden/comment_leaking_ignore_package.md
@@ -5,9 +5,11 @@
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.
-| Package | Leaked API symbols |
-| :--- | :--- |
-|package5|NonExported<br>NonExported2<br>TransitiveNonExported|
+| Package | Leaked API symbol | Leaking sources |
+| :--- | :--- | :--- |
+|package5|NonExported|package5_base.dart::Awesome::myClass|
+|package5|NonExported2|package5_base.dart::Awesome::myClass2|
+|package5|TransitiveNonExported|package5_base.dart::NonExported2::myClass|
This check can be disabled by tagging the PR with `skip-leaking-check`.