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

Refactoring code to reduce cognitive complexity from 16 to 15 in src/user/settings.js #46

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

Conversation

SarimFaraz
Copy link

@SarimFaraz SarimFaraz commented Sep 2, 2024

This pull request resolves issue #13

The purpose of this task is to reduce the cognitive complexity of the file src/user/settings.js

I broke the code down and made two new functions to reduce the cognitive complexity:

validatePaginationValue: This function checks if a given pagination value is within the acceptable range. If the value is not valid, it throws an error.

validateLanguage: This function checks if a given language code is included in the list of valid language codes. If the language code is not valid, it throws an error.

This makes the code easier to read, follow, and fixes the issues.

@coveralls
Copy link

coveralls commented Sep 2, 2024

Pull Request Test Coverage Report for Build 10705501656

Details

  • 9 of 10 (90.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.007%) to 82.678%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/user/settings.js 9 10 90.0%
Totals Coverage Status
Change from base Build 10550029021: 0.007%
Covered Lines: 22327
Relevant Lines: 25584

💛 - Coveralls

@SarimFaraz SarimFaraz changed the title made new functions in settings to make code complexity go from 16 to 15 Refactoring code to reduce cognitive complexity from 16 to 15 in src/user/settings.js Sep 4, 2024
…n test, and checked manual testing by checking user settings
Copy link

sonarcloud bot commented Sep 4, 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