timi-codes/Banka

View on GitHub
API/controllers/account.controller.js

Summary

Maintainability
A
2 hrs
Test Coverage

Showing 1 of 3 total issues

Function fetchAllAccounts has a Cognitive Complexity of 9 (exceeds 6 allowed). Consider refactoring.
Invalid

static async fetchAllAccounts(req, res) {
const { status } = req.query;
 
try {
if (status && !(['dormant', 'active'].includes(status))) {
Severity: Minor
Found in API/controllers/account.controller.js - About 45 mins to fix

Avoid too many return statements within this function.
Invalid

return response.sendError(res, 400, error.message);
Severity: Major
Found in API/controllers/account.controller.js - About 30 mins to fix

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    static async getAccount(req, res) {
    const { accountNumber } = req.params;
    try {
    const data = await AccountService.getAccount(accountNumber);
    return response.sendSuccess(res, 200, data, 'Account was successfully fetched');
    Severity: Major
    Found in API/controllers/account.controller.js and 1 other location - About 2 hrs to fix
    API/controllers/transaction.controller.js on lines 54..62
    Category
    Status