Refactor public/src/admin/appearance/themes.js:init to reduce complexity#65
Open
mhk2-cmu wants to merge 1 commit into
Open
Refactor public/src/admin/appearance/themes.js:init to reduce complexity#65mhk2-cmu wants to merge 1 commit into
mhk2-cmu wants to merge 1 commit into
Conversation
…rd clause and helpers
Author
|
I would like to work on this please! |
|
Great! I assigned you (@N624-debu) to the issue. Have fun working on it! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refactor
initinpublic/src/admin/appearance/themes.jsSummary
This PR refactors the
initfunction inpublic/src/admin/appearance/themes.jsto address a high complexity code smell detected by Qlty. The originalinitfunction contained deeply nested logic for theme selection and multiple inline operations.The refactor improves readability and maintainability by:
if (action !== 'use') return;).getThemeInfoFromto encapsulate DOM attribute lookups.applyThemeto handle socket emission and UI updates.initbody, which makes the control flow easier to follow.Evidence of Improvement
Before
Qlty reported:
After
After the refactor, complexity smell was removed. Qlty now reports:
This remaining warning is due to inline callbacks inside
init(returns in nested functions). However, the structure is significantly cleaner and more maintainable.Manual Validation
Issue Link
Resolves #46