processing / processing/p5.js-web-editor
Misleading function name in removeCollection controller
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1.7k
- Forks
- 1.7k
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 8
Description
p5.js version
p5.js Web Editor (repository: p5.js-web-editor)
What is your operating system?
Mac OS
Web browser and version
Chrome / Firefox (any) — not browser-specific
Actual Behavior
In the backend collections controller, the file removeCollection.js
exports a function named createCollection.
However, the function:
- Reads a collection ID from req.params
- Finds an existing collection owned by the user
- Calls
deleteOne()on the collection
There is no collection creation logic in this function. The name
createCollection is misleading and does not reflect the actual behavior.
Expected Behavior
The controller function name should clearly reflect its behavior.
In this case, the function name should indicate that it removes (deletes)
a collection, matching the file name and route usage.
Steps to reproduce
Steps:
- Navigate to
server/controllers/collection/collection.controller/removeCollection.js - Observe that the exported function is named
createCollection - Review the function logic and note that it deletes an existing collection using
deleteOne()
Snippet:
import Collection from '../../models/collection';
export default function createCollection(req, res) {
const { id: collectionId } = req.params;
const owner = req.user._id;
function sendFailure({ code = 500, message = 'Something went wrong' }) {
res.status(code).json({ success: false, message });
}
function sendSuccess() {
res.status(200).json({ success: true });
}
function removeCollection(collection) {
if (collection == null) {
sendFailure({
code: 404,
message: 'Not found, or you user does not own this collection'
});
return null;
}
return collection.deleteOne();
}
function findCollection() {
// Only returned if owner matches current user
return Collection.findOne({ _id: collectionId, owner }).exec();
}
return findCollection()
.then(removeCollection)
.then(sendSuccess)
.catch(sendFailure);
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with server/controllers/collection/collection.controller/removeCollection.js and inspect its export and route usage. Confirm the function finds the owned collection and calls deleteOne(), then rename the exported function to reflect removal without changing its behavior. Done means the name matches the file and route references remain consistent.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- backend
- Issue type
- Refactor
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 85/100