CMU-313 / NodeBB

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

Refactor code in src/middleware/admin.js to reduce cognitive complexity #558

Open e5z26 opened 2 months ago

e5z26 commented 2 months ago

I changed an else and nestled if into else if on a helper function. I also removed a condition in an if (leads to adding some number to the time) by changing it into having the number times a factor (that is 0 or 1 depending on the condition) being added to the time. At the end of the code, instead of using an else, I returned on the other conditions and ran what was in the else in the body of the function. resolves #481

sonarcloud[bot] commented 2 months ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

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

See analysis details on SonarCloud

coveralls commented 2 months ago

Pull Request Test Coverage Report for Build 10727519299

Details


Changes Missing Coverage Covered Lines Changed/Added Lines %
src/middleware/admin.js 10 12 83.33%
<!-- Total: 10 12 83.33% -->
Files with Coverage Reduction New Missed Lines %
src/meta/errors.js 1 76.74%
<!-- Total: 1 -->
Totals Coverage Status
Change from base Build 10607818019: -0.004%
Covered Lines: 22326
Relevant Lines: 25586

💛 - Coveralls