diff --git a/pkgs/firehose/CHANGELOG.md b/pkgs/firehose/CHANGELOG.md index 8ef84775..b5ee5080 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 a9130540..c1d28674 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -262,7 +262,7 @@ ${changeForPackage.entries.map((e) => '|${e.key.name}|${e.value.toMarkdownRow()} Future leakingCheck() async { var filesInPR = await listFilesInPRorAll(); - final leaksForPackage = >{}; + final leaksInPackages = <(Package, Leak)>[]; final flutterPackages = packagesContaining(filesInPR, only: flutterPackageGlobs); @@ -310,7 +310,10 @@ ${changeForPackage.entries.map((e) => '|${e.key.name}|${e.value.toMarkdownRow()} var leaks = decoded['missingEntryPoints'] as List; if (leaks.isNotEmpty) { - leaksForPackage[package] = leaks.cast(); + leaksInPackages.addAll(leaks.map( + (leakJson) => + (package, Leak.fromJson(leakJson as Map)), + )); final desc = leaks.map((item) => '$item').join(', '); log('Leaked symbols found: $desc.'); @@ -334,15 +337,13 @@ ${changeForPackage.entries.map((e) => '|${e.key.name}|${e.value.toMarkdownRow()} } 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('
')}|').join('\n')} +| Package | Leaked API symbol | Leaking sources | +| :--- | :--- | :--- | +${leaksInPackages.map((e) => '|${e.$1.name}|${e.$2.name}|${e.$2.usages.join('
')}|').join('\n')} ''', ); } @@ -548,6 +549,30 @@ ${isWorseThanInfo ? 'This check can be disabled by tagging the PR with `skip-${r } } +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 usages; + + final String name; + + Leak._({ + required this.type, + required this.usages, + required this.name, + }); + + factory Leak.fromJson(Map json) { + return Leak._( + type: json['type'] as String, + usages: (json['usages'] as List).cast(), + 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 949a88fa..c56ac761 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 b0abc3d2..4711c9cd 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
NonExported2
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 b0abc3d2..4711c9cd 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
NonExported2
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 b0abc3d2..4711c9cd 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
NonExported2
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`.