Add additional test cases to TestStaticImportRuleNormalizer#23
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR extends 🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Sorry, I missed seeing this before merging #24, though I think that one fixed it in a much simpler way. It looks like the test changes from this one are still useful. |
There was a problem hiding this comment.
Pull request overview
This PR fixes a case where StaticImportRuleNormalizer would remove a class import when rewriting qualified method calls into required static imports, even though the class is still referenced elsewhere (e.g., other static calls like copyOf(...) or as a type in method parameters).
Changes:
- Updates the normalizer to keep class imports when the class is still referenced via non-rewritten calls or in type positions.
- Fixes and extends
TestStaticImportRuleNormalizerto cover the previously broken case and add two regression scenarios.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| airstyle-core/src/main/java/io/airlift/airstyle/normalizer/StaticImportRuleNormalizer.java | Tracks additional class/type usages so required-static-import rewrites don’t incorrectly remove still-needed imports. |
| airstyle-core/src/test/java/io/airlift/airstyle/normalizer/TestStaticImportRuleNormalizer.java | Adjusts the existing required-static-import test and adds regression tests for “class still used” scenarios. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Looks like it :) I'll see if there are any test duplication and repurpose this PR for additional test coverage. |
6d2f852 to
873641a
Compare
There are various ways the type can remain used; the existing test case covers the case when the type is used to invoke a static method (other than the ones that are meant to be static-imported), these new test cases covers when the type is used as a method parameter or return type. Fortunately the fix in airlift#24 fixes those cases as well.
873641a to
1575391
Compare
There are various ways the type can remain used; the existing test case covers the case when the type is used to invoke a static method (other than the ones that are meant to be static-imported), these new test cases covers when the type is used as a method parameter or return type. Fortunately the fix in #24 fixes those cases as well.