Shegsdev/Banka

View on GitHub

Showing 73 of 73 total issues

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

  async findOneAndDelete(column, field, response) {
    try {
      const result = await DB.query(`DELETE FROM ${this.table} WHERE ${column} = '${field}'`);
      return result;
    } catch (err) {
Severity: Major
Found in server/utils/model.js and 1 other location - About 6 hrs to fix
server/utils/model.js on lines 44..60

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 170.

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

  async findBy(column, param, response) {
    try {
      const result = await DB.query(`SELECT * FROM ${this.table} WHERE ${column} = '${param}'`);
      return result;
    } catch (err) {
Severity: Major
Found in server/utils/model.js and 1 other location - About 6 hrs to fix
server/utils/model.js on lines 101..117

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 170.

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

        return res.status(201).json({
          status: 201,
          data: {
            transactionId: newTransaction.rows[0].transaction_id,
            accountNumber: newTransaction.rows[0].account_number,
Severity: Major
Found in server/controllers/accountsController.js and 1 other location - About 4 hrs to fix
server/controllers/accountsController.js on lines 304..314

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 133.

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

        return res.status(201).json({
          status: 201,
          data: {
            transactionId: newTransaction.rows[0].transaction_id,
            accountNumber: newTransaction.rows[0].account_number,
Severity: Major
Found in server/controllers/accountsController.js and 1 other location - About 4 hrs to fix
server/controllers/accountsController.js on lines 385..395

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 133.

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

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

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

        try {
          const decoded = jwt.verify(token, process.env.SECRET);
          const user = await User.findBy('email', decoded.username);
          if (user.rows[0].length < 1) {
            res.status(403).json({
    Severity: Major
    Found in server/middleware/verifyToken.js and 1 other location - About 3 hrs to fix
    server/controllers/usersController.js on lines 194..223

    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 98.

    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

        try {
          const decoded = await jwt.verify(token, process.env.SECRET);
          const user = await User.findBy('email', decoded.username, res);
          if (!user.rows.length) {
            res.status(403).json({
    Severity: Major
    Found in server/controllers/usersController.js and 1 other location - About 3 hrs to fix
    server/middleware/verifyToken.js on lines 18..44

    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 98.

    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 4 locations. Consider refactoring.
    Open

          Account.findAllById(res).then((accounts) => {
            if (!accounts || !accounts.rows.length) {
              return res.status(404).json({
                status: 404,
                error: 'No account found',
    Severity: Major
    Found in server/controllers/accountsController.js and 3 other locations - About 3 hrs to fix
    server/controllers/accountsController.js on lines 95..104
    server/controllers/accountsController.js on lines 437..449
    server/controllers/usersController.js on lines 27..36

    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 95.

    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 4 locations. Consider refactoring.
    Open

        User.findBy('id', parseInt(req.params.id, 10), res)
          .then((user) => {
            if (!user || !user.rows.length) {
              return res.status(403).json({
                status: 403,
    Severity: Major
    Found in server/controllers/usersController.js and 3 other locations - About 3 hrs to fix
    server/controllers/accountsController.js on lines 82..90
    server/controllers/accountsController.js on lines 95..104
    server/controllers/accountsController.js on lines 437..449

    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 95.

    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 4 locations. Consider refactoring.
    Open

        Account.findOneAndDelete('account_number', parseInt(accountNumber, 10), res)
          .then((result) => {
            if (!result || !result.rows.length) {
              return res.status(404).json({
                status: 404,
    Severity: Major
    Found in server/controllers/accountsController.js and 3 other locations - About 3 hrs to fix
    server/controllers/accountsController.js on lines 82..90
    server/controllers/accountsController.js on lines 95..104
    server/controllers/usersController.js on lines 27..36

    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 95.

    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 4 locations. Consider refactoring.
    Open

          Account.findBy('status', status, res)
            .then((accounts) => {
              if (!accounts || !accounts.rows.length) {
                return res.status(404).json({
                  status: 404,
    Severity: Major
    Found in server/controllers/accountsController.js and 3 other locations - About 3 hrs to fix
    server/controllers/accountsController.js on lines 82..90
    server/controllers/accountsController.js on lines 437..449
    server/controllers/usersController.js on lines 27..36

    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 95.

    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 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

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

                                res.status(200).send({
                                  status: 200,
                                  data: {
                                    token,
                                    id: user.id,
                Severity: Major
                Found in server/controllers/auth/signinController.js and 1 other location - About 1 hr to fix
                server/controllers/auth/signupController.js on lines 73..82

                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 70.

                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 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

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

                            return res.status(201).json({
                              status: 201,
                              data: {
                                token,
                                id: user.id,
                Severity: Major
                Found in server/controllers/auth/signupController.js and 1 other location - About 1 hr to fix
                server/controllers/auth/signinController.js on lines 52..61

                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 70.

                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

                Severity
                Category
                Status
                Source
                Language