feat: add cat lookup/removal and python geometry helpers - #65
Open
tsah-baz wants to merge 4 commits into
Open
Conversation
MergerPending The reviewer’s unresolved medium-severity concern is unaddressed: remove(name) deletes only the first duplicate-named cat, leaving others. Author action or an explicit semantic decision is needed before re-evaluation. Commit |
Comment on lines
+24
to
+29
| remove(name: string): Promise<void> { | ||
| const index = this.cats.findIndex((candidate) => candidate.name === name); | ||
| if (index === -1) { | ||
| throw new NotFoundException(`No cat named ${name}`); | ||
| } | ||
| this.cats.splice(index, 1); |
There was a problem hiding this comment.
Removal leaves duplicate named cats
create doesn't enforce unique names, so an admin can add two cats with the same name — then remove(name) deletes only the first match and leaves the duplicate, so the name persists — should we enforce uniqueness on insert or make remove/findByName address all matches?
Want Baz to fix this for you? Activate Fixer
Prompt for AI Agents
Before applying, verify this suggestion against the current code. In
`typescript/nestjs/src/cats/cats.service.ts` around lines 24-29, the `remove(name)`
method deletes only the first matching cat (it uses `findIndex` + `splice(index, 1)`),
which breaks correctness when duplicate `name` entries exist. Refactor by making the
service’s duplicate semantics consistent: either enforce unique `name` when creating
cats (add a pre-insert check and throw an appropriate HTTP error like conflict), or
change `remove(name)` to remove all cats with that `name` (e.g., filter/splice all
matches) so `findByName(name)` no longer returns a remaining entry after removal. Ensure
the corresponding logic for `findByName(name)` (and any `create` method) aligns with the
chosen semantics and add/update tests to cover duplicate removal.
Author
|
Baz summarize |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds name-based lookup and removal to the NestJS cats service, and a small python geometry helper module for area calculations.
Testing: ran the nestjs unit tests locally.