CMU-313 / NodeBB

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

Refactored code in scr/flags.js to reduce the cognitive complexity from 27 to 15 #546

Open zhanwen22 opened 2 months ago

zhanwen22 commented 2 months ago

In the function Flags.update located in scr/flags.js there was a cognitive complexity issue due to the overly nested code and many unnecessary if statements. This was fixed by breaking down a big function into smaller functions and reducing or statements, ultimately leading to cleaner code.

Edit to add: TA told me that my coverage was ok, because it was from a file that I did not work on. So I reverted my test cases to the original ones, because that caused the least SonarCloud errors.

This resolves https://github.com/CMU-313/NodeBB/issues/519 with the SonarCloud issue: https://sonarcloud.io/project/issues?cleanCodeAttributeCategories=ADAPTABLE&directories=src&impactSeverities=HIGH&impactSoftwareQualities=MAINTAINABILITY&issueStatuses=OPEN%2CCONFIRMED&id=CMU-313_NodeBB&open=AZFmjARHybYwxy-_uEfu&tab=code

coveralls commented 2 months ago

Pull Request Test Coverage Report for Build 10728962106

Details


Totals Coverage Status
Change from base Build 10607818019: 0.001%
Covered Lines: 22325
Relevant Lines: 25584

💛 - Coveralls
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