Skip to content

Conversation

@OmerGursoy04
Copy link

P1B: Starter Task: Refactoring PR

Use this pull request template to briefly answer the questions below in one to two sentences each.
Feel free to delete this text at the top after filling out the template.

You are not permitted to use generative AI services (e.g., ChatGPT) to compose the answers.
Any such use will be treated as a violation of academic integrity.

1. Issue

Link to the associated GitHub issue:

**Full path to the refactored file: **

  • public/src/modules/navigator.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 manages the transitions between pages. Also, when a user is using navigating through the page, such as + by pressing buttons, it handles what happens and how that click is processed.

What is the scope of your refactoring within that file?
(Name specific functions/blocks/regions touched.)

  • I changed navigator.init
  • just the params entered and added a line below the function definition

Which Qlty‑reported issue did you address?
(Name the rule/metric and include the BEFORE value; e.g., “Cognitive Complexity 18 in render()”.)

  • 32 Function with many parameters (count = 5): init

2. Refactoring

How did the specific issue you chose impact the codebase’s maintainability?

  • If a new parameter were to be added to that function, the order of the input would matter when that function is being
  • called and if I didn't look at that code for a long time or I passed it on to a collaborator, it would make their lives more
  • difficult.

What changes did you make to resolve the issue?

  • I removed the 5 params and put ...args inside as the function param.
  • added the params as an array assigning them to args.

How do your changes improve maintainability? Did you consider alternatives?

  • It was a very simple fix but I don't think it really improves the maintainability.
  • Perhaps a better fix would be to use an if-else block to map arguments with their corresponding values. This would
  • make the function order invariant.

3. Validation

How did you trigger the refactored code path from the UI?

  • I had two logs.
  • First log: I clicked on announcements.
  • Second log: When I clicked on the post under general discussion.

Attach a screenshot of the logs and UI demonstrating the trigger.

Screenshot 2026-01-23 at 18 55 36 Screenshot 2026-01-23 at 18 57 22

(If you refactored a public/src/ file (front-end related file), watch logging via DevTools (Ctrl+Shift+I to open and then navigate to the 'Console' tab). If you refactored a src/ file, watch logging via ./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.

Screenshot 2026-01-23 at 20 37 06

Omer Gursoy added 2 commits January 23, 2026 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant