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

src/flags.js (Refactor this function to reduce its Cognitive Complexity from 18 to the 15 allowed.) #60

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

Conversation

ssaigh
Copy link

@ssaigh ssaigh commented Sep 2, 2024

This pull request resolves issue #10
Resolves #10

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

@coveralls
Copy link

coveralls commented Sep 2, 2024

Pull Request Test Coverage Report for Build 10719473390

Details

  • 6 of 8 (75.0%) changed or added relevant lines in 1 file are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.01%) to 82.685%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/flags.js 6 8 75.0%
Files with Coverage Reduction New Missed Lines %
src/flags.js 2 78.96%
Totals Coverage Status
Change from base Build 10550029021: 0.01%
Covered Lines: 22328
Relevant Lines: 25585

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