tolulope-od/banka

View on GitHub
server/controllers/TransactionController.js

Summary

Maintainability
C
1 day
Test Coverage

Function creditAccount has 81 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  static async creditAccount(req, res) {
    const { accountNumber } = req.params;
    const { creditAmount } = req.body;
    if (req.decoded.type !== 'staff') {
      return res.status(401).json({
Severity: Major
Found in server/controllers/TransactionController.js - About 3 hrs to fix

    Function debitAccount has 81 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      static async debitAccount(req, res) {
        const { accountNumber } = req.params;
        const { debitAmount } = req.body;
        if (req.decoded.type !== 'staff') {
          return res.status(401).json({
    Severity: Major
    Found in server/controllers/TransactionController.js - About 3 hrs to fix

      Function getSpecificTransaction has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        static async getSpecificTransaction(req, res) {
          const { transactionId } = req.params;
          const { id, type } = req.decoded;
          if (type === 'client') {
            const userAccountTransaction = await transactions.select(
      Severity: Minor
      Found in server/controllers/TransactionController.js - About 1 hr to fix

        Avoid too many return statements within this function.
        Open

            return res.status(200).json({
              status: 200,
              data: [data],
              message: 'Account credited successfully'
            });
        Severity: Major
        Found in server/controllers/TransactionController.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                return res.status(400).json({
                  status: 400,
                  error: `Insufficient funds, your account balance is ${balance}`
                });
          Severity: Major
          Found in server/controllers/TransactionController.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                return res.status(200).json({
                  status: 200,
                  data: [data],
                  message: 'Account debited successfully'
                });
            Severity: Major
            Found in server/controllers/TransactionController.js - About 30 mins to fix

              There are no issues that match your filters.

              Category
              Status