Showing 43 of 43 total issues
Function handleStatusChange
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const handleStatusChange = () => {
const currentStatus = document.getElementById('accnt-status-btn').innerHTML;
let newStatus;
if (currentStatus === 'Deactivate Account') {
newStatus = 'dormant';
Function signIn
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
static async signIn(req, res) {
const { email, password } = req.body;
const findUser = await users.select(['*'], [`email='${email}'`]);
if (findUser.length > 0) {
const verifyPassword = bcrypt.compareSync(password, findUser[0].password);
Function signUp
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
static signUp(req, res) {
const { firstName, lastName, email, password } = req.body;
const existingUser = users.some(user => user.email === email);
if (existingUser) {
return res.status(409).json({
Function fetchSingleAccount
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const fetchSingleAccount = event => {
const reference = event.target.getAttribute('data-account-number');
const accountNumber = parseInt(reference, 10);
localStorage.setItem('banka-account-number', accountNumber);
event.preventDefault();
Function signUp
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
static async signUp(req, res) {
const { firstName, lastName, email, password } = req.body;
const existingUser = await users.select(['email'], [`email='${email}'`]);
if (existingUser.length > 0) {
return res.status(409).json({
Function fetchSingleAccount
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const fetchSingleAccount = event => {
const reference = event.target.getAttribute('data-account-number');
const accountNumber = parseInt(reference, 10);
localStorage.setItem('banka-account-number', accountNumber);
event.preventDefault();
Function adminAddStaff
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
static async adminAddStaff(req, res) {
if (req.decoded.isAdmin) {
const { userEmail } = req.body;
const findUser = await users.select(['*'], [`email='${userEmail}'`]);
Function editAccountStatus
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
static async editAccountStatus(req, res) {
const { accountNumber } = req.params;
const { status } = req.body;
if (req.decoded.type !== 'staff') {
return res.status(401).json({
Function createAccount
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
static createAccount(req, res) {
const { type } = req.body;
const { id, firstName, lastName, email } = req.decoded;
if (req.decoded.type === 'client') {
const newAccount = new Account();
Function editAccountStatus
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
static editAccountStatus(req, res) {
const { accountNumber } = req.params;
const { status } = req.body;
if (req.decoded.type !== 'staff') {
return res.status(401).json({
Function handleAccountDebit
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const handleAccountDebit = () => {
const debitAmount = document.getElementById('debit-amount').value;
const debitBtn = document.getElementById('debit-btn');
const accountNumber = localStorage.getItem('banka-account-number-view');
const token = localStorage.getItem('banka-app-token');
Function handleAccountCredit
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const handleAccountCredit = () => {
const creditAmount = document.getElementById('credit-amount').value;
const creditBtn = document.getElementById('credit-btn');
const accountNumber = localStorage.getItem('banka-account-number-view');
const token = localStorage.getItem('banka-app-token');
Function signIn
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
static signIn(req, res) {
const { email, password } = req.body;
for (let i = 0; i < users.length; i += 1) {
if (email === users[i].email && password === users[i].password) {
const userInfo = users[i];
Function getSpecificTransaction
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
static async getSpecificTransaction(req, res) {
const { transactionId } = req.params;
const { id, type } = req.decoded;
if (type === 'client') {
const userAccountTransaction = await transactions.select(
Function createAccount
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
static async createAccount(req, res) {
const { type } = req.body;
const { id, firstName, lastName, email } = req.decoded;
if (req.decoded.type === 'client') {
const accountNumber = Math.floor(Math.random() * 10 ** 10);
Function getTransactionHistory
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
static async getTransactionHistory(req, res) {
const { accountNumber } = req.params;
const { id, type } = req.decoded;
const selectedAccount = await accounts.select(
['*'],
Function fetchAllAccountsByUser
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
static async fetchAllAccountsByUser(req, res) {
const { userEmail } = req.params;
let userAccounts;
if (req.decoded.type !== 'staff') {
if (req.decoded.email !== userEmail) {
Function handleAccountDelete
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const handleAccountDelete = () => {
const accountNumber = localStorage.getItem('banka-account-number-view');
const token = localStorage.getItem('banka-app-token');
const headers = new Headers();
headers.append('Content-Type', 'application/json');
Avoid too many return
statements within this function. Open
Open
return res.status(200).json({
status: 200,
data: [data],
message: 'Account credited successfully'
});
Avoid too many return
statements within this function. Open
Open
return res.status(400).json({
status: 400,
error: `Insufficient funds, your account balance is ${balance}`
});