Skip to content

Reduced complexity in the file src/user/create.js#39

Open
hangyiw wants to merge 2 commits into
CMU-17313Q:mainfrom
hangyiw:refactor-user-creation
Open

Reduced complexity in the file src/user/create.js#39
hangyiw wants to merge 2 commits into
CMU-17313Q:mainfrom
hangyiw:refactor-user-creation

Conversation

@hangyiw
Copy link
Copy Markdown

@hangyiw hangyiw commented Sep 4, 2025

Changes Made

Extracted logic from the create function in src/user/create.js into two
helper functions:

  • createUserData: Builds initial user data object
  • initializeUser: Handles database operations and notifications

This reduces cyclomatic complexity from 11 to improve maintainability. Resolves #36.

Testing

  • Ran npm lint and npm test - all passing
  • Verified with qlty that complexity was reduced
  • Tested user registration flow through UI: clicked register button, entered
    username/password, accepted terms, and successfully created account
  • Confirmed expected console output appeared in logs immediately following registration

@coveralls
Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 17487719375

Details

  • 16 of 16 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.002%) to 78.531%

Totals Coverage Status
Change from base Build 17472903245: 0.002%
Covered Lines: 24695
Relevant Lines: 29609

💛 - Coveralls

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.

P1B: Refactor (src/user/create.js): Function with high complexity (count = 11): create

2 participants