Showing 34 of 73 total issues
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';
Function addStaff
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
addStaff(req, res) {
const {
firstName, lastName, email, password, type,
} = req.body;
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 => {
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,
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);
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,
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 });
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';
- Read upRead up
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 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,
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 : '';
- Read upRead up
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 : '';
- Read upRead up
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 });
}
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 : '';
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,
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,
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 : '';
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';
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' });
}
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,
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) {