Shegsdev/Banka

View on GitHub

Showing 34 of 73 total issues

File accountsController.js has 338 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* eslint-disable consistent-return */
import User from '../models/user';
import Account from '../models/account';
import Transaction from '../models/transaction';
import validateCreateBankAccountInput from '../validation/bankAccount';
Severity: Minor
Found in server/controllers/accountsController.js - About 4 hrs to fix

    Function addStaff has 68 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      addStaff(req, res) {
        const {
          firstName, lastName, email, password, type,
        } = req.body;
    
    
    Severity: Major
    Found in server/controllers/usersController.js - About 2 hrs to fix

      Function getAllUsers has 64 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function getAllUsers(config) {
          const url = new URL(env.url());
          fetch(`${url.href}/users/`, config)
          .then(response => response.json())
          .then(json => {
      Severity: Major
      Found in client/assets/js/queries.js - About 2 hrs to fix

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

          async debitAccount(req, res) {
            const { accountNumber } = req.params;
            if (/[A-Za-z]+/g.test(accountNumber)) {
              return res.status(400).json({
                status: 400,
        Severity: Major
        Found in server/controllers/accountsController.js - About 2 hrs to fix

          Function signup has 58 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            signup(req, res) {
              const {
                firstName, lastName, email, password,
              } = req.body;
              const { errors, isValid } = validateSignUpInput(req.body);
          Severity: Major
          Found in server/controllers/auth/signupController.js - About 2 hrs to fix

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

              async creditAccount(req, res) {
                const { accountNumber } = req.params;
                if (/[A-Za-z]+/g.test(accountNumber)) {
                  return res.status(400).json({
                    status: 400,
            Severity: Major
            Found in server/controllers/accountsController.js - About 2 hrs to fix

              Function signin has 48 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                signin(req, res) {
                  const { email, password } = req.body;
                  const { errors, isValid } = validateSignInInput(req.body);
                  if (!isValid) {
                    return res.status(400).send({ status: 400, error: errors });
              Severity: Minor
              Found in server/controllers/auth/signinController.js - About 1 hr to fix

                Function onscroll has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                window.onscroll = function () {
                  if (window.scrollY > 50) {
                    // nav
                    nav.style.position = 'fixed';
                    nav.style.background = '#fff';
                Severity: Minor
                Found in client/assets/js/partials.js - About 1 hr to fix

                Cognitive Complexity

                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                A method's cognitive complexity is based on a few simple rules:

                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                • Code is considered more complex for each "break in the linear flow of the code"
                • Code is considered more complex when "flow breaking structures are nested"

                Further reading

                Function changeStatus has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  changeStatus(req, res) {
                    const { accountNumber } = req.params;
                    if (/[A-Za-z]+/g.test(accountNumber)) {
                      return res.status(400).json({
                        status: 400,
                Severity: Minor
                Found in server/controllers/accountsController.js - About 1 hr to fix

                  Function validateSignUpInput has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                  const validateSignUpInput = (data) => {
                    const errors = {};
                    data.firstName = !isEmpty(data.firstName) ? data.firstName : '';
                    data.lastName = !isEmpty(data.lastName) ? data.lastName : '';
                    data.email = !isEmpty(data.email) ? data.email : '';
                  Severity: Minor
                  Found in server/validation/authentication/signUp.js - About 1 hr to fix

                  Cognitive Complexity

                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                  A method's cognitive complexity is based on a few simple rules:

                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                  • Code is considered more complex for each "break in the linear flow of the code"
                  • Code is considered more complex when "flow breaking structures are nested"

                  Further reading

                  Function validateCreateBankAccountInput has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                  const validateCreateBankAccountInput = (data) => {
                    const errors = {};
                    data.firstName = !isEmpty(data.firstName) ? data.firstName : '';
                    data.lastName = !isEmpty(data.lastName) ? data.lastName : '';
                    data.email = !isEmpty(data.email) ? data.email : '';
                  Severity: Minor
                  Found in server/validation/bankAccount.js - About 1 hr to fix

                  Cognitive Complexity

                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                  A method's cognitive complexity is based on a few simple rules:

                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                  • Code is considered more complex for each "break in the linear flow of the code"
                  • Code is considered more complex when "flow breaking structures are nested"

                  Further reading

                  Function create has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    async create(req, res) {
                      const { errors, isValid } = validateCreateBankAccountInput(req.body);
                      if (!isValid) {
                        return res.status(400).json({ status: 400, error: errors });
                      }
                  Severity: Minor
                  Found in server/controllers/accountsController.js - About 1 hr to fix

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

                    const validateSignUpInput = (data) => {
                      const errors = {};
                      data.firstName = !isEmpty(data.firstName) ? data.firstName : '';
                      data.lastName = !isEmpty(data.lastName) ? data.lastName : '';
                      data.email = !isEmpty(data.email) ? data.email : '';
                    Severity: Minor
                    Found in server/validation/authentication/signUp.js - About 1 hr to fix

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

                        async getType(req, res) {
                          const token = req.headers['x-access-token'];
                          if (!token) {
                            return res.status(401).json({
                              status: 401,
                      Severity: Minor
                      Found in server/controllers/usersController.js - About 1 hr to fix

                        Function tokenVerify has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          async tokenVerify(req, res, next) {
                            const token = req.headers['x-access-token'];
                            if (!token) {
                              return res.status(401).json({
                                status: 401,
                        Severity: Minor
                        Found in server/middleware/verifyToken.js - About 1 hr to fix

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

                          const validateCreateBankAccountInput = (data) => {
                            const errors = {};
                            data.firstName = !isEmpty(data.firstName) ? data.firstName : '';
                            data.lastName = !isEmpty(data.lastName) ? data.lastName : '';
                            data.email = !isEmpty(data.email) ? data.email : '';
                          Severity: Minor
                          Found in server/validation/bankAccount.js - About 1 hr to fix

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

                            window.onscroll = function () {
                              if (window.scrollY > 50) {
                                // nav
                                nav.style.position = 'fixed';
                                nav.style.background = '#fff';
                            Severity: Minor
                            Found in client/assets/js/partials.js - About 1 hr to fix

                              Function findOne has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                async findOne(req, res) {
                                  const { transactionId } = req.params;
                                  if (!transactionId || !isFinite(transactionId)) {
                                    return res.status(400).json({ status: 400, error: 'Invalid transaction id' });
                                  }
                              Severity: Minor
                              Found in server/controllers/transactionsController.js - About 1 hr to fix

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

                                  delete(req, res) {
                                    const { accountNumber } = req.params;
                                    if (/[A-Za-z]+/g.test(accountNumber)) {
                                      return res.status(400).json({
                                        status: 400,
                                Severity: Minor
                                Found in server/controllers/accountsController.js - About 1 hr to fix

                                  Function findAll has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                    findAll(req, res) {
                                      const { status } = req.query;
                                      if (JSON.stringify(req.query) == '{}') {
                                        Account.findAllById(res).then((accounts) => {
                                          if (!accounts || !accounts.rows.length) {
                                  Severity: Minor
                                  Found in server/controllers/accountsController.js - About 1 hr to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language