meetKazuki/QuickCredit

View on GitHub

Showing 21 of 21 total issues

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

function getUsers() {
  const url = 'http://localhost:4500/api/v1/users';
  const token = window.localStorage.getItem('token');

  return fetch(url, {
Severity: Major
Found in ui/assets/js/getUsers.js and 1 other location - About 5 hrs to fix
ui/assets/js/userDashboard.js on lines 67..84

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

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

function getUserLoans() {
  const url = 'http://localhost:4500/api/v1/user/loans';
  const token = window.localStorage.getItem('token');

  return fetch(url, {
Severity: Major
Found in ui/assets/js/userDashboard.js and 1 other location - About 5 hrs to fix
ui/assets/js/getUsers.js on lines 48..65

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

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

function getRepayments(id) {
  const url = `http://localhost:4500/api/v1/loans/${id}/repayments`;
  const token = window.localStorage.getItem('token');

  return fetch(url, {
Severity: Major
Found in ui/assets/js/userDashboard.js and 2 other locations - About 5 hrs to fix
ui/assets/js/getLoans.js on lines 85..99
ui/assets/js/getUsers.js on lines 68..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 138.

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

function getOneRecord(id) {
  const url = `http://localhost:4500/api/v1/loans/${id}`;
  const token = window.localStorage.getItem('token');

  return fetch(url, {
Severity: Major
Found in ui/assets/js/getLoans.js and 2 other locations - About 5 hrs to fix
ui/assets/js/getUsers.js on lines 68..82
ui/assets/js/userDashboard.js on lines 87..101

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

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

function getUser(email) {
  const url = `http://localhost:4500/api/v1/users/${email}`;
  const token = window.localStorage.getItem('token');

  return fetch(url, {
Severity: Major
Found in ui/assets/js/getUsers.js and 2 other locations - About 5 hrs to fix
ui/assets/js/getLoans.js on lines 85..99
ui/assets/js/userDashboard.js on lines 87..101

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

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

    if (repaid) {
      query = `SELECT * FROM loans WHERE repaid='${repaid}'`;
      const { rows } = await DB.query(query);
      res.status(200).json({
        status: 200,
Severity: Major
Found in server/src/controllers/loanController.js and 1 other location - About 2 hrs to fix
server/src/controllers/loanController.js on lines 105..114

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

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

    if (status) {
      query = `SELECT * FROM loans WHERE status='${status}'`;
      const { rows } = await DB.query(query);
      res.status(200).json({
        status: 200,
Severity: Major
Found in server/src/controllers/loanController.js and 1 other location - About 2 hrs to fix
server/src/controllers/loanController.js on lines 115..124

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

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

  static async createLoan(req, res) {
    const { email } = req.user;
    const { amount, tenor } = req.body;
    const loan = {
      email,
Severity: Major
Found in server/src/controllers/loanController.js - About 2 hrs to fix

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

      fetch(url, {
        method: 'POST',
        headers: {
          Authorization: `Bearer ${token}`,
          'Content-Type': 'application/json',
    Severity: Major
    Found in ui/assets/js/createLoan.js and 1 other location - About 1 hr to fix
    ui/assets/js/createRepayment.js on lines 5..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 74.

    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

      fetch(url, {
        method: 'POST',
        headers: {
          Authorization: `Bearer ${token}`,
          'Content-Type': 'application/json',
    Severity: Major
    Found in ui/assets/js/createRepayment.js and 1 other location - About 1 hr to fix
    ui/assets/js/createLoan.js on lines 14..31

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

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

    function convertUTCToLocalTime(timeString) {
      const dateObj = new Date(timeString);
      const formatDate = new Intl.DateTimeFormat('en-GB', {
        day: '2-digit',
        month: 'short',
    Severity: Major
    Found in ui/assets/js/userDashboard.js and 2 other locations - About 1 hr to fix
    ui/assets/js/getLoans.js on lines 18..27
    ui/assets/js/getUsers.js on lines 4..13

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

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

    function convertUTCToLocalTime(timeString) {
      const dateObj = new Date(timeString);
      const formatDate = new Intl.DateTimeFormat('en-GB', {
        day: '2-digit',
        month: 'short',
    Severity: Major
    Found in ui/assets/js/getLoans.js and 2 other locations - About 1 hr to fix
    ui/assets/js/getUsers.js on lines 4..13
    ui/assets/js/userDashboard.js on lines 18..27

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

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

    function convertUTCToLocalTime(timeString) {
      const dateObj = new Date(timeString);
      const formatDate = new Intl.DateTimeFormat('en-GB', {
        day: '2-digit',
        month: 'short',
    Severity: Major
    Found in ui/assets/js/getUsers.js and 2 other locations - About 1 hr to fix
    ui/assets/js/getLoans.js on lines 18..27
    ui/assets/js/userDashboard.js on lines 18..27

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

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

      static async getAllLoans(req, res) {
        const { status, repaid } = req.query;
        let query;
    
        if (status && repaid) {
    Severity: Minor
    Found in server/src/controllers/loanController.js - About 1 hr to fix

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

      function authenticateUser(userObj, endpoint) {
        const url = `http://localhost:4500/api/v1/auth/${endpoint}`;
        const element = document.querySelector('button[type="submit"]');
        const defaultText = element.textContent;
        let defaultRole = 'user';
      Severity: Minor
      Found in ui/assets/js/authenticateUser.js - About 1 hr to fix

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

          static async createUser(req, res) {
            const {
              firstname, lastname, address, email, password,
            } = req.body;
            const hashedPassword = HelperUtils.hashPassword(password);
        Severity: Minor
        Found in server/src/controllers/userController.js - About 1 hr to fix

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

            static async postRepayment(req, res) {
              const { id } = req.params;
              const paidAmount = parseInt(req.body.paidAmount, 10);
              const query = `SELECT * FROM loans WHERE id='${id}'`;
              let repaid = false;
          Severity: Minor
          Found in server/src/controllers/repaymentController.js - About 1 hr to fix

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

              static async updateLoan(req, res) {
                const { id } = req.params;
                const { status } = req.body;
                const query = `SELECT * FROM loans WHERE id='${id}'`;
                const update = `UPDATE loans
            Severity: Minor
            Found in server/src/controllers/loanController.js - About 1 hr to fix

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

              function renderLoanRecords(recordObj) {
                const list = document.getElementById('record-list');
                const row = document.createElement('tr');
                const {
                  id,
              Severity: Minor
              Found in ui/assets/js/userDashboard.js - About 1 hr to fix

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

                    if (findUser.rows[0].status === 'verified') {
                      res.status(409).json({
                        status: 409,
                        error: 'User is already verified',
                      });
                Severity: Minor
                Found in server/src/controllers/userController.js and 1 other location - About 55 mins to fix
                server/src/controllers/loanController.js on lines 36..42

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

                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