timi-codes/Banka

View on GitHub

Showing 48 of 58 total issues

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

const getUserTransactions = (accountNumber) => {
const transactionUrl = `${baseUrl}/accounts/${accountNumber}/transactions`;
fetch(transactionUrl, {
headers: {
'Content-Type': 'application/json',
Severity: Major
Found in frontend/js/dashboard.js and 1 other location - About 1 day to fix
frontend/js/customer.js on lines 112..143

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

const getUserTransactions = accountNumber => {
const transactionUrl = `${baseUrl}/accounts/${accountNumber}/transactions`;
fetch(transactionUrl, {
headers: {
"Content-Type": "application/json",
Severity: Major
Found in frontend/js/customer.js and 1 other location - About 1 day to fix
frontend/js/dashboard.js on lines 223..254

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

if (account.balance >= amount) {
const user = await User.findUserById(Number(account.owner));
 
const transaction = await Transaction.debit(account, amount, cashierId);
 
 
Severity: Major
Found in API/services/transaction.service.js and 1 other location - About 6 hrs to fix
API/services/transaction.service.js on lines 71..96

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

if (account) {
const user = await User.findUserById(Number(account.owner));
 
const transaction = await Transaction.credit(account, amount, cashierId);
 
 
Severity: Major
Found in API/services/transaction.service.js and 1 other location - About 6 hrs to fix
API/services/transaction.service.js on lines 28..53

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

const fetchUserAccount = url => {
fetch(url, {
headers: {
"Content-Type": "application/json",
"x-access-token": `Bearer ${token}`
Severity: Major
Found in frontend/js/customer.js and 1 other location - About 6 hrs to fix
frontend/js/dashboard.js on lines 289..316

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

const fetchUserAccount = (url) => {
fetch(url, {
headers: {
'Content-Type': 'application/json',
'x-access-token': `Bearer ${token}`,
Severity: Major
Found in frontend/js/dashboard.js and 1 other location - About 6 hrs to fix
frontend/js/customer.js on lines 270..297

File dashboard.js has 445 lines of code (exceeds 300 allowed). Consider refactoring.
Open

const accountModal = document.getElementById('accountModal');
const account = document.getElementById('account-button');
const profileModal = document.getElementById('profileModal');
const profile = document.getElementById('profile-button');
const baseUrl = 'https://banka-timi.herokuapp.com/api/v1';
Severity: Minor
Found in frontend/js/dashboard.js - About 5 hrs to fix

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

    const showAlert = (color, message) => {
    elem.innerHTML = message;
    elem.classList.add('slider');
    elem.style.display = 'block';
    elem.style.opacity = 1;
    Severity: Major
    Found in frontend/js/dashboard.js and 1 other location - About 4 hrs to fix
    frontend/js/customer.js on lines 50..62

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

    const showAlert = (color, message) => {
    elem.innerHTML = message;
    elem.classList.add("slider");
    elem.style.display = "block";
    elem.style.opacity = 1;
    Severity: Major
    Found in frontend/js/customer.js and 1 other location - About 4 hrs to fix
    frontend/js/dashboard.js on lines 69..81

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

    static async creditUserAccount(req, res) {
    const { amount } = req.body;
    const { id } = req.token;
    const { accountNumber } = req.params;
     
     
    Severity: Major
    Found in API/controllers/transaction.controller.js and 1 other location - About 4 hrs to fix
    API/controllers/transaction.controller.js on lines 16..27

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

    static async debitUserAccount(req, res) {
    const { amount } = req.body;
    const { id } = req.token;
    const { accountNumber } = req.params;
     
     
    Severity: Major
    Found in API/controllers/transaction.controller.js and 1 other location - About 4 hrs to fix
    API/controllers/transaction.controller.js on lines 35..46

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

    const fadeOutEffect = () => {
    const fadeTarget = document.getElementById("alert");
    const fadeEffect = setInterval(() => {
    if (!fadeTarget.style.opacity) {
    fadeTarget.style.opacity = 1;
    Severity: Major
    Found in frontend/js/customer.js and 1 other location - About 4 hrs to fix
    frontend/js/dashboard.js on lines 52..64

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

    const fadeOutEffect = () => {
    const fadeTarget = document.getElementById('alert');
    const fadeEffect = setInterval(() => {
    if (!fadeTarget.style.opacity) {
    fadeTarget.style.opacity = 1;
    Severity: Major
    Found in frontend/js/dashboard.js and 1 other location - About 4 hrs to fix
    frontend/js/customer.js on lines 33..45

    File customer.js has 339 lines of code (exceeds 300 allowed). Consider refactoring.
    Open

    const accountModal = document.getElementById("accountModal");
    const body = document.getElementsByTagName("body")[0];
    const baseUrl = "https://banka-timi.herokuapp.com/api/v1";
    const content = document.querySelector(".content");
    const tableDiv = document.querySelectorAll(".tableDiv");
    Severity: Minor
    Found in frontend/js/customer.js - About 2 hrs to fix

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

      static async getAccount(req, res) {
      const { accountNumber } = req.params;
      try {
      const data = await AccountService.getAccount(accountNumber);
      return response.sendSuccess(res, 200, data, 'Account was successfully fetched');
      Severity: Major
      Found in API/controllers/account.controller.js and 1 other location - About 2 hrs to fix
      API/controllers/transaction.controller.js on lines 54..62

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

      static async getTransactions(req, res) {
      const { accountNumber } = req.params;
      try {
      const data = await TransactionService.getAllTransactions(accountNumber);
      return response.sendSuccess(res, 200, data, 'Transactions was successfully fetched');
      Severity: Major
      Found in API/controllers/transaction.controller.js and 1 other location - About 2 hrs to fix
      API/controllers/account.controller.js on lines 83..91

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

      return transactions.map((transaction) => {
      const {
      id, transactiontype, accountnumber, createdon, oldbalance, newbalance, ...data
      } = transaction;
       
       
      Severity: Major
      Found in API/services/transaction.service.js and 1 other location - About 2 hrs to fix
      API/services/transaction.service.js on lines 144..158

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

      if (transaction) {
      const {
      id, transactiontype, accountnumber, createdon, oldbalance, newbalance, ...data
      } = transaction;
       
       
      Severity: Major
      Found in API/services/transaction.service.js and 1 other location - About 2 hrs to fix
      API/services/transaction.service.js on lines 114..128

      Function successLogic has 56 lines of code (exceeds 30 allowed). Consider refactoring.
      Open

      const successLogic = data => {
      if (data.data.length > 0) {
      tableDiv[0].style.display = "block";
      if (credit) {
      credit.style.visibility = "visible";
      Severity: Major
      Found in frontend/js/customer.js - About 2 hrs to fix

        Function onclick has 52 lines of code (exceeds 30 allowed). Consider refactoring.
        Open

        trasactButton.onclick = () => {
        if (amountTextField.value === "" || amountTextField.value === null) {
        errorTag[0].innerHTML = "Enter an amount";
        } else if (!amountTextField.value.match(/^\d+(\.\d{1,2})?$/)) {
        errorTag[0].innerHTML = "Enter a valid amount";
        Severity: Major
        Found in frontend/js/customer.js - About 1 hr to fix
          Severity
          Category
          Status
          Source
          Language