Skip to content

Conversation

@avalonsueiro
Copy link

P1B: Starter Task: Refactoring PR

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

Please provide a link to the associated GitHub issue:

Link to the associated GitHub issue: https://github.com/CMU-313/NodeBB/issues/270

Full path to the refactored file: src/plugins/data.js

What do you think this file does?
This file has something to do with loading the CSS for the platform.

What is the scope of your refactoring within that file?
I changed only the function Data.getStaticDirectories.

Which Qlty‑reported issue did you address?
7 return statements in getStaticDirectories.

2. Refactoring

How did the specific issue you chose impact the codebase’s adaptability?
These changes made it so that it is easier to follow the progress of the code so that there are less endpoints where it might return to the previous function. Instead it will exit in only a few predictable places.

What changes did you make to resolve the issue?
I used ChatGPT to rewrite the code so that there were less return statements needed.

How do your changes improve adaptability? Did you consider alternatives?
I did consider alternatives, however my first two ideas would have made the code much more complex with if statements. The rewritten code in this way keeps out unnecessary complexity while also not introducing new errors.

3. Validation

How did you trigger the refactored code path from the UI?
Since my code was involved with loading CSS information for the code, it was triggered when I loaded the site, accessed pages/user pages. I was able to trigger it just by accessing the site.

Attach a screenshot of the logs and UI demonstrating the trigger.
Screenshot 2025-09-09 at 11 12 04 PM
Screenshot 2025-09-09 at 10 16 15 PM

Attach a screenshot of qlty smells --no-snippets <full/path/to/file.js> showing fewer reported issues after the changes.
Screenshot 2025-09-09 at 11 14 00 PM

@coveralls
Copy link

Pull Request Test Coverage Report for Build 17602156882

Details

  • 4 of 11 (36.36%) changed or added relevant lines in 1 file are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.02%) to 78.546%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/plugins/data.js 4 11 36.36%
Files with Coverage Reduction New Missed Lines %
src/plugins/data.js 1 78.35%
Totals Coverage Status
Change from base Build 17435863312: 0.02%
Covered Lines: 24695
Relevant Lines: 29603

💛 - Coveralls

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.

2 participants