Showing 34 of 117 total issues
File validators.js
has 407 lines of code (exceeds 250 allowed). Consider refactoring. Open
const bytes = require('bytes');
const fs = require('fs');
const tmp = require('tmp');
const validator = require('validator');
File chesSvc.js
has 286 lines of code (exceeds 250 allowed). Consider refactoring. Open
/**
* @module ChesService
*
* Create a business service for CHES.
* Provide a wrapper around business functions that use multiple services.
Function findPromoteMessages
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
async findPromoteMessages(client, messageId, status, tag, transactionId) {
if (!client) {
throw new Problem(400, { detail: 'Error finding and promoting messages. Client cannot be null' });
}
Function findCancelMessages
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
async findCancelMessages(client, messageId, status, tag, transactionId) {
if (!client) {
throw new Problem(400, { detail: 'Error finding and cancelling messages. Client cannot be null' });
}
Function attachments
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
attachments: async (obj, attachmentSizeLimit = DEFAULT_ATTACHMENT_SIZE) => {
const errors = [];
if (obj.attachments) {
if (!Array.isArray(obj.attachments)) {
errors.push({ value: undefined, message: 'Invalid value `attachments`. Expect an array of attachments.' });
Function initializeConnections
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
function initializeConnections() {
// Initialize connections and exit if unsuccessful
try {
const tasks = [
dataConnection.checkAll(),
Function promoteMessage
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
async promoteMessage(client, messageId) {
if (!client || !messageId) {
throw new Problem(400, { detail: 'Error promoting message. Client and messageId cannot be null' });
}
- 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 cancelMessage
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
async cancelMessage(client, messageId) {
if (!client || !messageId) {
throw new Problem(400, { detail: 'Error cancelling message. Client and messageId cannot be null' });
}
- 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 contexts
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
contexts: obj => {
const errors = [];
if (obj.contexts) {
if (!Array.isArray(obj.contexts)) {
errors.push({ value: undefined, message: 'Invalid value `contexts`. Expect an array of contexts.' });
Function default
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function (data) {
console.log(`VU: ${__VU} - ITER: ${__ITER}`);
console.debug('Running Tests');
console.debug(`Data from setup: ${JSON.stringify(data)}`);
if (!data.token) {
Function up
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.up = function (knex) {
const statusTable = (table) => {
table.uuid('messageId').references('messageId').inTable('message').notNullable().index();
table.string('status').notNullable().defaultTo('accepted');
Function relationMappings
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
static relationMappings () {
const Queue = require('./queue');
const Status = require('./status');
const Trxn = require('./trxn');
return {
Function sendEmailMerge
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
async sendEmailMerge(client, template, ethereal = false) {
if (!template) {
throw new Problem(400, { detail: 'Error sending email merge. Email templates/contexts cannot be null' });
}
if (!ethereal && !client) {
Function updateStatus
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
async updateStatus(client, messageId, status, description) {
let trx;
try {
trx = await Message.startTransaction();
Function setup
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function setup() {
console.log(`Email url: ${emailUrl}`);
console.log(`SSO url: ${oidcUrl}`);
console.debug('Getting Token');
// Check a secret was supplied or nothing will work
Function promoteMessage
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
async promoteMessage(client, messageId) {
if (!client || !messageId) {
throw new Problem(400, { detail: 'Error promoting message. Client and messageId cannot be null' });
}
Function cancelMessage
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
async cancelMessage(client, messageId) {
if (!client || !messageId) {
throw new Problem(400, { detail: 'Error cancelling message. Client and messageId cannot be null' });
}
Function _createClient
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
const _createClient = () => {
let redis;
const redisOpts = {
enableReadyCheck: false, // Bull forcibly assumes Redis is ready if it has connected to it
Function close
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
close(cb = undefined) {
if (this.queue) {
try {
this.queue.whenCurrentJobsFinished().then(() => {
this.queue.close().then(() => {
- 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 updateStatus
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
async updateStatus(client, messageId, status, description) {
let trx;
try {
trx = await Message.startTransaction();
- 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"