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 in src/controllers/mods.js #68

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

Conversation

mayTkhin24
Copy link

Resolves #39

I refactored code in src/controllers/mods.js to reduce cognitive complexity which was 20.

Several helper functions were added to make the code easier to read and simpler to debug. The helper functions are as follows:

initialize(req): Sets up needed data.
checkAccess(...): Checks user permissions and updates local variables.
parseFilters(req, filters): Processes filter parameters from the request.
adjustFiltersForMod(filters, res): Updates filters based on moderation.
determineHasFilter(filters): Checks if filters are applied.
parseSort(req, sorts): Handles sorting parameters.
fetchData(req, filters, sort): Retrieves the required data.
getSelectedUsers(filters): Gets user details for selected filters.

mkhin24 and others added 2 commits September 3, 2024 10:49
…eck access, parse and adjust filters, fetch data and getting selected users
refactoring mods.js to reduce cognitive complexity
@coveralls
Copy link

coveralls commented Sep 3, 2024

Pull Request Test Coverage Report for Build 10720589831

Details

  • 25 of 26 (96.15%) changed or added relevant lines in 1 file are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.02%) to 82.69%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/controllers/mods.js 25 26 96.15%
Files with Coverage Reduction New Missed Lines %
src/controllers/mods.js 2 76.03%
Totals Coverage Status
Change from base Build 10550029021: 0.02%
Covered Lines: 22336
Relevant Lines: 25592

💛 - Coveralls

Copy link

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

Refactoring code in src/controllers/mods.js
3 participants