CMU-313 / NodeBB

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

Refactored src/controllers/topics.js to reduce its cognitive complexity #527

Open elliay opened 2 months ago

elliay commented 2 months ago

Refactored the getTopic function to reduce its Cognitive Complexity from 38 to the 15 allowed by splitting up the function into smaller helper functions.

This resolves #436

Helper functions added:

isInvalidRequest getUserData isAccessRestricted isTopicUnreadable handleSpecialCases needsSlugRedirect isInvalidPostIndex getSortOption getSetAndReverseOptions

sonarcloud[bot] commented 2 months ago

Quality Gate Passed Quality Gate passed

Issues
2 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 10713844511

Details


Changes Missing Coverage Covered Lines Changed/Added Lines %
src/controllers/topics.js 26 27 96.3%
<!-- Total: 26 27 96.3% -->
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.002%
Covered Lines: 22335
Relevant Lines: 25595

💛 - Coveralls