Conversation
WalkthroughThe PR refactors the Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ❌ 3❌ Failed checks (2 warnings, 1 inconclusive)
✏️ 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.
🧹 Nitpick comments (1)
src/core/game/PlayerImpl.ts (1)
216-233: Returning internal_unitsarray directly for no-args / empty-array case.When called with no arguments (line 227) or an empty array (line 233),
units()returns the rawthis._unitsreference. Callers that mutate the returned array (e.g.,splice,push) would corrupt internal state. This is likely pre-existing behavior, but worth noting: the empty-array path (len === 0) now also exposes the raw reference, matching the no-args path.Current callers appear safe (they chain
.filter()/.sort()which create new arrays), so this is not a blocker.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/core/game/PlayerImpl.ts` around lines 216 - 233, The units method currently returns the internal this._units array directly when called with no arguments or an empty array, exposing internal state to mutation; update PlayerImpl.units so both the no-args path and the empty-array branch return a shallow copy of this._units (e.g., using slice or spread) instead of the raw array to prevent callers from mutating internal state; ensure the change is applied inside the units(...) function around the early returns for a === undefined and len === 0 while keeping all other type-filtering behavior unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/core/game/PlayerImpl.ts`:
- Around line 216-233: The units method currently returns the internal
this._units array directly when called with no arguments or an empty array,
exposing internal state to mutation; update PlayerImpl.units so both the no-args
path and the empty-array branch return a shallow copy of this._units (e.g.,
using slice or spread) instead of the raw array to prevent callers from mutating
internal state; ensure the change is applied inside the units(...) function
around the early returns for a === undefined and len === 0 while keeping all
other type-filtering behavior unchanged.
If this PR fixes an issue, link it below. If not, delete these two lines.
Resolves #(issue number)
Description:
Describe the PR.
Please complete the following:
Please put your Discord username so you can be contacted if a bug or regression is found:
DISCORD_USERNAME