fix: match from_package selection against component's own package#26
fix: match from_package selection against component's own package#26
Conversation
Version AnalysisNext Version: Changelog: 📄 View detailed changelog in job summary |
There was a problem hiding this comment.
Pull request overview
Fixes from_package magnitude override selection so it matches components defined in a given external package (via package: URI filePath), not only components whose superclass originated from that package—addressing missed overrides for re-exported classes.
Changes:
- Extend
from_packagematching to also compare against the component’s own package parsed fromcomponent.filePath. - Add focused unit tests covering direct-package matching, non-matches, multi-package lists, magnitude downgrades, and enclosing-context behavior.
- Add a regression test to ensure superclass-package matching still works.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| test/comparators/apply_overrides_test.dart | Adds test coverage for from_package matching via package: file paths and regression guards. |
| lib/doc_comparator/apply_overrides.dart | Implements own-package matching by parsing package: URIs from filePath in selection context. |
Comments suppressed due to low confidence (1)
lib/doc_comparator/apply_overrides.dart:112
- In the
fromPackageloop,context.ownPackageis evaluated for every configured package, and it currently parses the URI each time. For large change sets and multiple overrides, this adds avoidable overhead. Consider computingfinal ownPackage = context.ownPackage;once before the loop (or caching it in_SelectionContext) and comparing against that.
if (selection.fromPackage != null) {
bool packageMatched = false;
for (final package in selection.fromPackage!) {
// Match if the component is defined in the package (via its filePath)
if (context.ownPackage == package) {
packageMatched = true;
break;
}
// Also match if the component's superclass comes from the package
if (context.superClassPackages.contains(package)) {
packageMatched = true;
break;
}
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Version AnalysisNext Version: Changelog: 📄 View detailed changelog in job summary |
Version AnalysisNext Version: Changelog: 📄 View detailed changelog in job summary |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The
from_packageselection in magnitude overrides only matched components whose superclass came from the specified package, not components defined in that package. So if you re-export classes from an upstream package (likepatrol) and configure:...changes to classes like
AndroidSelector— which is defined inpatrol, not subclassing anything from it — would still show up in every changelog. The override was silently doing nothing for them.Fixed by also checking
context.ownPackage(extracted from the component'spackage:URIfilePath) against thefrom_packagelist. Added tests for the new behaviour and a regression guard for the existing superclass-package path.