Refactor (src/user/index.js:75): reduce parameter count (getUsersFromSet) #1
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.
P1B: Starter Task: Refactoring PR
1. Issue
Please provide a link to the associated GitHub issue:
CMU-313/NodeBB#1
Link to the associated GitHub issue:
CMU-313/NodeBB#1
Full path to the refactored file:
src/user/index.js
What do you think this file does?
(Your answer does not have to be 100% correct; give a reasonable, evidence‑based guess.)
I think this file provides many of the core user operations (e.g fetching users from Redis, mapping usernames/emails to uids, and status checks). My evidence-based guess stems from playing around trying to trigger console.log().
What is the scope of your refactoring within that file?
(Name specific functions/blocks/regions touched.)
I only changed User.getUsersFromSet (starting at line 75). I changed its default and argument handling from 4 to 3 while trying to keep behavior the same. I did not change any other functions/blocks/regions.
Which Qlty‑reported issue did you address?
(Name the rule/metric and include the BEFORE value; e.g., “Cognitive Complexity 18 in render()”.)
Qlty reported the issue as "Function with many parameters (count = 4)" for getUsersFromSet. After I refactored, the warning no longer shows
2. Refactoring
How did the specific issue you chose impact the codebase’s adaptability?
From my perspective, four sequential parameters seemed to make the function easy to misuse (e.g. argument order). And it makes it more difficult to extend safely without touching other callers.
What changes did you make to resolve the issue?
I reduced the parameters from 4 to 3 (set, uid, start) and set defined defaults (start=0, stop=-1). And I tried to preserve its functionality/behavior by reading an optional fourth argument through arguments[3]
How do your changes improve adaptability? Did you consider alternatives?
The new 3 parameter function is harder to misuse and still works with old calls. It improves readability and future edits without interrupting old calls. I considered adding a small helper class to hold start/stop, but ended up choosing the smallest change so nothing else needed updates.
3. Validation
How did you trigger the refactored code path from the UI?
I followed the writeup by adding console.log('Ryan Wang') then ran ./nodebb log. I was able to trigger the console.log() by visiting User -> Banned/Most Flags/Most Reputation, Groups -> Admin (members)/Global Moderators(members). Screen Shots of UI + triggered logs ('Ryan Wang') are posted below.
Attach a screenshot of the logs and UI demonstrating the trigger.
(Run
./nodebb log; include the relevant UI view. Temporary logs should be removed before final commit.)Attach a screenshot of

qlty smells --no-snippets <full/path/to/file.js>showing fewer reported issues after the changes.