Skip to content

Reduced return statements in src/controllers/admin.js#40

Open
tbouri wants to merge 3 commits into
CMU-17313Q:mainfrom
tbouri:refactor-admin
Open

Reduced return statements in src/controllers/admin.js#40
tbouri wants to merge 3 commits into
CMU-17313Q:mainfrom
tbouri:refactor-admin

Conversation

@tbouri
Copy link
Copy Markdown

@tbouri tbouri commented Sep 4, 2025

Resolves #31

Summary
Addressed excessive return statements in src/controllers/admin.js by modifying adminController.routeIndex.

Changes made
Added a redirect mapping of admin privileges to routes in order to loop over it and check if users have one of the "privileges". If so, they are sent to the corresponding admin page. This removes the long chain of the if conditions in the original code, therefore, removing smells.

Validation
Reran qlty smell to ensure issue is resolved. As well as npm run lint and npm run test.

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/controllers/admin.js

1 participant