refactor(filter): restore scripts from decompiled to source version#201
refactor(filter): restore scripts from decompiled to source version#201zndxcvbn wants to merge 3 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThree filter classes in the ChangesFilter Type Safety and Class Structure
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
There was a problem hiding this comment.
Actionable comments posted: 6
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@source/actionscript/Common/skyui/filter/IFiIlter.as`:
- Line 1: The filename contains a typo: rename the file currently named
IFiIlter.as to exactly IFilter.as so it matches the declared interface
skyui.filter.IFilter; ensure the filesystem and any references/imports use the
new filename (IFilter.as) so the ActionScript compiler can resolve the
interface.
- Around line 3-5: Uncomment and restore the interface method signature in
IFiIlter by adding the applyFilter declaration (public function
applyFilter(filteredItems:Array):Void;) so implementations like ItemTypeFilter
implement the contract; ensure the parameter name matches the implementation
(filteredItems) and include the :Void return type to match ItemTypeFilter.as.
In `@source/actionscript/Common/skyui/filter/ItemTypeFilter.as`:
- Line 76: Change the a_flag parameter type from Boolean to Number for both
entryMatchesFilter and entryMatchesPartitionedFilter (they are declared as
a_flag: Boolean now) because the code performs numeric/bitwise operations
((a_entry.filterFlag & a_flag), comparisons like a_flag == 0xFFFFFFFF, byte0 ==
a_flag) and call sites pass _itemFilter (Number); update the signatures to
a_flag: Number and add explicit :Boolean return type annotations to the
functions to reflect they return a boolean result.
- Line 12: The getter function get itemFilter is missing an explicit return
type; update the getter declaration (function get itemFilter) to include the
return type annotation ": Number" so the signature reads get itemFilter():
Number and ensure any returned value matches Number to satisfy the typed
refactor.
- Line 68: The isMatch function's a_flag parameter is untyped; update the
signature of isMatch to declare a_flag: Number and add a Boolean return type
(e.g., isMatch(a_entry: Object, a_flag: Number): Boolean) so it matches the
typed refactor and the matcher functions it delegates to.
In `@source/actionscript/Common/skyui/filter/SortFilter.as`:
- Around line 29-35: The sort config can be null/unset causing runtime errors;
add defensive guards in setSortBy and applyFilter to handle null/undefined/empty
values: in setSortBy (function setSortBy) ensure that when a_sortAttributes or
a_sortOptions is null/undefined you assign safe defaults (e.g., empty arrays)
and only update this._sortAttributes/this._sortOptions with validated arrays; in
applyFilter (method applyFilter) early-return or skip sorting when
this._sortAttributes or this._sortOptions are null/empty and ensure any code
that iterates or indexes into these members checks length before use so sorting
is only attempted with valid arrays.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: e345ee9f-a23d-4b42-8f20-afe77503eb28
📒 Files selected for processing (3)
source/actionscript/Common/skyui/filter/IFiIlter.assource/actionscript/Common/skyui/filter/ItemTypeFilter.assource/actionscript/Common/skyui/filter/SortFilter.as
| public function setSortBy(a_sortAttributes: Array, a_sortOptions: Array) | ||
| { | ||
| if (this._sortAttributes == a_sortAttributes && this._sortOptions == a_sortOptions) | ||
| return; | ||
|
|
||
| this._sortAttributes = a_sortAttributes; | ||
| this._sortOptions = a_sortOptions; |
There was a problem hiding this comment.
Add defensive guards for unset/null sort config before sorting.
applyFilter assumes _sortAttributes/_sortOptions are initialized and non-empty. If setSortBy is skipped or receives null, this will throw at runtime.
Suggested fix
public function setSortBy(a_sortAttributes: Array, a_sortOptions: Array)
{
+ if (a_sortAttributes == null || a_sortOptions == null || a_sortAttributes.length == 0)
+ return;
+
if (this._sortAttributes == a_sortAttributes && this._sortOptions == a_sortOptions)
return;
this._sortAttributes = a_sortAttributes;
this._sortOptions = a_sortOptions;
@@
public function applyFilter(a_filteredList: Array)
{
+ if (a_filteredList == null || this._sortAttributes == null || this._sortOptions == null || this._sortAttributes.length == 0)
+ return;
+
var primaryAttribute = this._sortAttributes[0];Also applies to: 41-57
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@source/actionscript/Common/skyui/filter/SortFilter.as` around lines 29 - 35,
The sort config can be null/unset causing runtime errors; add defensive guards
in setSortBy and applyFilter to handle null/undefined/empty values: in setSortBy
(function setSortBy) ensure that when a_sortAttributes or a_sortOptions is
null/undefined you assign safe defaults (e.g., empty arrays) and only update
this._sortAttributes/this._sortOptions with validated arrays; in applyFilter
(method applyFilter) early-return or skip sorting when this._sortAttributes or
this._sortOptions are null/empty and ensure any code that iterates or indexes
into these members checks length before use so sorting is only attempted with
valid arrays.
Summary by CodeRabbit
Refactor
Chores