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 public/src/admin/extend/widgets.js to reduce Cognitive Complexity #47 #179

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

SenseiAK
Copy link

Resolves #47

This is a new pull request following PR #48 with modifications including the console.log() as well as a test file in the /tests folder.

The nested if statements and the excessive use of operators within them were driving the cognitive complexity of the forEach function to 16, surpassing the acceptable limit of 15. To address this, I refactored the function by isolating and grouping related conditions into separate, well-defined helper functions, simplifying the main function's logic and improving readability.

This was tested by running npm run lint and npm run test, both passing with no new errors. Test file WidgetsTest.js was written with AI tools.

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 public/src/admin/extend/widgets.js
1 participant