Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 13 commits into
base: f24
Choose a base branch
from

Conversation

zhanwen22
Copy link

@zhanwen22 zhanwen22 commented Sep 5, 2024

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 #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

@zhanwen22 zhanwen22 closed this Sep 5, 2024
@zhanwen22 zhanwen22 reopened this Sep 5, 2024
@coveralls
Copy link

coveralls commented Sep 5, 2024

Pull Request Test Coverage Report for Build 10728962106

Details

  • 11 of 11 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.001%) to 82.672%

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

💛 - Coveralls

Copy link

sonarcloud bot commented Sep 5, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactoring code in src/flags.js
2 participants