tolulope-od/banka

View on GitHub

Showing 43 of 43 total issues

Function handleStatusChange has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const handleStatusChange = () => {
  const currentStatus = document.getElementById('accnt-status-btn').innerHTML;
  let newStatus;
  if (currentStatus === 'Deactivate Account') {
    newStatus = 'dormant';
Severity: Minor
Found in www/js/fetchSingleAccountHistory.js - About 1 hr to fix

    Function signIn has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      static async signIn(req, res) {
        const { email, password } = req.body;
        const findUser = await users.select(['*'], [`email='${email}'`]);
        if (findUser.length > 0) {
          const verifyPassword = bcrypt.compareSync(password, findUser[0].password);
    Severity: Minor
    Found in server/controllers/AuthController.js - About 1 hr to fix

      Function signUp has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        static signUp(req, res) {
          const { firstName, lastName, email, password } = req.body;
          const existingUser = users.some(user => user.email === email);
          if (existingUser) {
            return res.status(409).json({
      Severity: Minor
      Found in server/dummyControllers/AuthController.js - About 1 hr to fix

        Function fetchSingleAccount has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const fetchSingleAccount = event => {
          const reference = event.target.getAttribute('data-account-number');
          const accountNumber = parseInt(reference, 10);
          localStorage.setItem('banka-account-number', accountNumber);
          event.preventDefault();
        Severity: Minor
        Found in www/js/accounts.js - About 1 hr to fix

          Function signUp has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            static async signUp(req, res) {
              const { firstName, lastName, email, password } = req.body;
              const existingUser = await users.select(['email'], [`email='${email}'`]);
              if (existingUser.length > 0) {
                return res.status(409).json({
          Severity: Minor
          Found in server/controllers/AuthController.js - About 1 hr to fix

            Function fetchSingleAccount has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const fetchSingleAccount = event => {
              const reference = event.target.getAttribute('data-account-number');
              const accountNumber = parseInt(reference, 10);
              localStorage.setItem('banka-account-number', accountNumber);
              event.preventDefault();
            Severity: Minor
            Found in www/js/fetchAccounts.js - About 1 hr to fix

              Function adminAddStaff has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                static async adminAddStaff(req, res) {
                  if (req.decoded.isAdmin) {
                    const { userEmail } = req.body;
                    const findUser = await users.select(['*'], [`email='${userEmail}'`]);
              
              
              Severity: Minor
              Found in server/controllers/UserController.js - About 1 hr to fix

                Function editAccountStatus has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  static async editAccountStatus(req, res) {
                    const { accountNumber } = req.params;
                    const { status } = req.body;
                    if (req.decoded.type !== 'staff') {
                      return res.status(401).json({
                Severity: Minor
                Found in server/controllers/AccountController.js - About 1 hr to fix

                  Function createAccount has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    static createAccount(req, res) {
                      const { type } = req.body;
                      const { id, firstName, lastName, email } = req.decoded;
                      if (req.decoded.type === 'client') {
                        const newAccount = new Account();
                  Severity: Minor
                  Found in server/dummyControllers/AccountController.js - About 1 hr to fix

                    Function editAccountStatus has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      static editAccountStatus(req, res) {
                        const { accountNumber } = req.params;
                        const { status } = req.body;
                        if (req.decoded.type !== 'staff') {
                          return res.status(401).json({
                    Severity: Minor
                    Found in server/dummyControllers/AccountController.js - About 1 hr to fix

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

                      const handleAccountDebit = () => {
                        const debitAmount = document.getElementById('debit-amount').value;
                        const debitBtn = document.getElementById('debit-btn');
                        const accountNumber = localStorage.getItem('banka-account-number-view');
                        const token = localStorage.getItem('banka-app-token');
                      Severity: Minor
                      Found in www/js/fetchSingleAccountHistory.js - About 1 hr to fix

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

                        const handleAccountCredit = () => {
                          const creditAmount = document.getElementById('credit-amount').value;
                          const creditBtn = document.getElementById('credit-btn');
                          const accountNumber = localStorage.getItem('banka-account-number-view');
                          const token = localStorage.getItem('banka-app-token');
                        Severity: Minor
                        Found in www/js/fetchSingleAccountHistory.js - About 1 hr to fix

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

                            static signIn(req, res) {
                              const { email, password } = req.body;
                              for (let i = 0; i < users.length; i += 1) {
                                if (email === users[i].email && password === users[i].password) {
                                  const userInfo = users[i];
                          Severity: Minor
                          Found in server/dummyControllers/AuthController.js - About 1 hr 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

                              Function createAccount has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                static async createAccount(req, res) {
                                  const { type } = req.body;
                                  const { id, firstName, lastName, email } = req.decoded;
                                  if (req.decoded.type === 'client') {
                                    const accountNumber = Math.floor(Math.random() * 10 ** 10);
                              Severity: Minor
                              Found in server/controllers/AccountController.js - About 1 hr to fix

                                Function getTransactionHistory has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  static async getTransactionHistory(req, res) {
                                    const { accountNumber } = req.params;
                                    const { id, type } = req.decoded;
                                    const selectedAccount = await accounts.select(
                                      ['*'],
                                Severity: Minor
                                Found in server/controllers/AccountController.js - About 1 hr to fix

                                  Function fetchAllAccountsByUser has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                    static async fetchAllAccountsByUser(req, res) {
                                      const { userEmail } = req.params;
                                      let userAccounts;
                                      if (req.decoded.type !== 'staff') {
                                        if (req.decoded.email !== userEmail) {
                                  Severity: Minor
                                  Found in server/controllers/UserController.js - About 1 hr to fix

                                    Function handleAccountDelete has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                    const handleAccountDelete = () => {
                                      const accountNumber = localStorage.getItem('banka-account-number-view');
                                      const token = localStorage.getItem('banka-app-token');
                                      const headers = new Headers();
                                      headers.append('Content-Type', 'application/json');
                                    Severity: Minor
                                    Found in www/js/fetchSingleAccountHistory.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
                                          Severity
                                          Category
                                          Status
                                          Source
                                          Language