CMU-313 / NodeBB

GNU General Public License v3.0
0 stars 223 forks source link

Refactored code in public/src/client/account/settings.js to reduce complexity. #571

Open jullia02 opened 2 months ago

jullia02 commented 2 months ago

This PR refactors the saveSettings() function in settings.js, reducing cognitive complexity from 17 to 15 to improve readability and for simplicity. This was done by making multiple helper functions handleNewSettings(), processNewSettings(), and checkAndUpdateConfig().

This PR resolves #570, with the sonar cloud warning: https://sonarcloud.io/project/issues?open=AZFmi_ySybYwxy-_uEQC&id=CMU-313_NodeBB

This refactored code is covered by the test file: ./test/public/src/settings.js

UI Test Instructions

  1. Click on profile icon on top right.
  2. Click on Settings
  3. Change either the language/skin/home page setting.
  4. Click on "Save changes". This should print the console log message.
Screenshot 2024-09-05 at 8 19 20 PM
coveralls commented 2 months ago

Pull Request Test Coverage Report for Build 10730309223

Details


Totals Coverage Status
Change from base Build 10607818019: 0.0%
Covered Lines: 22323
Relevant Lines: 25582

💛 - Coveralls
sonarcloud[bot] commented 2 months ago

Quality Gate Passed Quality Gate passed

Issues
1 New issue
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud