Shegsdev/Banka

View on GitHub

Showing 73 of 73 total issues

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

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

        isStaff(req, res, next) {
          if (req.user.isStaff === false) {
            return res.status(403).json({
              status: 403,
              error: 'Forbidden',
      Severity: Major
      Found in server/middleware/admin.js and 1 other location - About 1 hr to fix
      server/middleware/admin.js on lines 2..10

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 66.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

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

        isAdmin(req, res, next) {
          if (req.user.isAdmin === false) {
            return res.status(403).json({
              status: 403,
              error: 'Forbidden',
      Severity: Major
      Found in server/middleware/admin.js and 1 other location - About 1 hr to fix
      server/middleware/admin.js on lines 12..20

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 66.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      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

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

                    const transactionDetail = {
                      type: 'credit',
                      account_number: accountNumber,
                      cashier: req.user.id,
                      amount,
            Severity: Major
            Found in server/controllers/accountsController.js and 1 other location - About 1 hr to fix
            server/controllers/accountsController.js on lines 376..383

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 62.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

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

                    const transactionDetail = {
                      type: 'debit',
                      account_number: accountNumber,
                      cashier: req.user.id,
                      amount,
            Severity: Major
            Found in server/controllers/accountsController.js and 1 other location - About 1 hr to fix
            server/controllers/accountsController.js on lines 295..302

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 62.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            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

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

                    if (account.rows[0].owner !== req.user.id) {
                      return res.status(403).json({ status: 403, err: 'Unauthorized access' });
                    }
              Severity: Major
              Found in server/controllers/transactionsController.js and 1 other location - About 1 hr to fix
              server/controllers/transactionsController.js on lines 73..75

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 61.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

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

                    if (account.rows[0].owner !== req.user.id) {
                      return res.status(403).json({ status: 403, err: 'Unauthorized access' });
                    }
              Severity: Major
              Found in server/controllers/transactionsController.js and 1 other location - About 1 hr to fix
              server/controllers/transactionsController.js on lines 36..38

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 61.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              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

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

                        findOne(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 modalOpen has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        function modalOpen(bool, action = 'undefined') {
                          if (bool) {
                            modal.style.display = 'block';
                            modalContent.innerHTML = '';
                            // Delete form
                        Severity: Minor
                        Found in client/assets/js/main.js - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language