Showing 73 of 73 total issues
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 });
}
Similar blocks of code found in 2 locations. Consider refactoring. Open
isStaff(req, res, next) {
if (req.user.isStaff === false) {
return res.status(403).json({
status: 403,
error: 'Forbidden',
- Read upRead up
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 66.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
isAdmin(req, res, next) {
if (req.user.isAdmin === false) {
return res.status(403).json({
status: 403,
error: 'Forbidden',
- Read upRead up
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 66.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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,
Similar blocks of code found in 2 locations. Consider refactoring. Open
const transactionDetail = {
type: 'credit',
account_number: accountNumber,
cashier: req.user.id,
amount,
- Read upRead up
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 62.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
const transactionDetail = {
type: 'debit',
account_number: accountNumber,
cashier: req.user.id,
amount,
- Read upRead up
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 62.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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 : '';
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (account.rows[0].owner !== req.user.id) {
return res.status(403).json({ status: 403, err: 'Unauthorized access' });
}
- Read upRead up
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 61.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (account.rows[0].owner !== req.user.id) {
return res.status(403).json({ status: 403, err: 'Unauthorized access' });
}
- Read upRead up
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 61.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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) {
Function findOne
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
findOne(req, res) {
const { accountNumber } = req.params;
if (/[A-Za-z]+/g.test(accountNumber)) {
return res.status(400).json({
status: 400,
Function modalOpen
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function modalOpen(bool, action = 'undefined') {
if (bool) {
modal.style.display = 'block';
modalContent.innerHTML = '';
// Delete form