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

Refactor src/flags.js #29

Merged
merged 1 commit into from
Sep 21, 2024
Merged

Conversation

ssaigh
Copy link

@ssaigh ssaigh commented Sep 19, 2024

File name: src/flags.js

Refactoring the flag.validate function to reduce complexity by removing the nest if statements. This reduces the complexity from 18 to 15, thus removing the sonar cloud warning. Fix Cognitive Complexity in src/flags.js.

Changes to the original code to reduce complexity:

Removed unnecessary else if statement: I removed the else if conditions in Flags.validate because each of the conditionals contained throws, which would automatically make you return and leave the function. Through doing this, I was able to remove deep nested if statements which reduced its complexity.

@jdufitum jdufitum merged commit 2cf97eb into CMU-17313Q:f24 Sep 21, 2024
1 check passed
@ssaigh ssaigh changed the title Added the refactored code Refactor src/flags.js Sep 22, 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.

2 participants