CMU-313 / NodeBB

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

Reduce cognitive complexity of function in src/topics/posts.js #543

Closed ldlin1 closed 2 months ago

ldlin1 commented 2 months ago

Refactored the function addEventStartEnd in src/topics/posts.js to reduce its cognitive complexity from 23 to the 15 allowed. This was done through the creation and use of the helper functions processPost, processLastPost, setEventStartEnd, and getNextPost

The refactored code passed the linter and test suite when run. Changes were also tested manually with console logs when interacting with the UI.

This pull request resolves #379

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 10724557352

Details


Totals Coverage Status
Change from base Build 10607818019: -0.001%
Covered Lines: 22328
Relevant Lines: 25587

💛 - Coveralls
ldlin1 commented 2 months ago

There is one line in the code I added (line 84) that isn't covered by the tests, but the equivalent line in the original code (line 80) also isn't covered by the tests. The decrease in test coverage can most likely be attributed to the increased amount of code in the file due to my additions.