Showing 20 of 93 total issues
Function createSaveToRedis
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
function createSaveToRedis(redis, message) {
return function saveToRedis(data) {
const { plan, plans } = data;
const { meta, level, title } = message;
const aliasedId = message.alias || plan.id;
Function saveToRedis
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
return function saveToRedis(data) {
const { plan, plans } = data;
const { meta, level, title } = message;
const aliasedId = message.alias || plan.id;
const hidden = message.hidden || false;
Function updateRedis
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
function updateRedis(sale) {
const { redis } = this;
const { state } = sale;
if (state !== 'approved') {
Function processKeys
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
function processKeys(amqp) {
const { config, log, redis } = this;
const { keyPrefix } = config.redis.options;
const masterNode = getRedisMasterNode(redis, config);
const pipeline = redis.pipeline();
Function cleanupCache
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
function cleanupCache(_index) {
const { redis, redisType, config } = this;
const { keyPrefix } = config.redis.options;
const keyPrefixLength = keyPrefix.length;
const index = `${keyPrefix}${_index}`;
Function agreementExecute
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
async function agreementExecute({ params }) {
const { config, redis, amqp } = this;
const { token } = params;
let agreementData;
- 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 getUsers
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function getUsers(ctx, opts = {}) {
const { audience, amqp, usersList, pulledUsers, pool } = ctx;
// give 5 minutes based on due date
const current = opts.start || moment().subtract(5, 'minutes').valueOf();
Function sendRequest
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function sendRequest(config, message) {
const defaultMerchantPreferences = {
return_url: config.urls.plan_return,
cancel_url: config.urls.plan_cancel,
auto_bill_amount: 'YES',
Function saveAgreement
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
async function saveAgreement(redis, token, agreement, owner, planId, creatorTaskId, finalizedAt) {
Function fetchUpdatedAgreement
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
async function fetchUpdatedAgreement(paypalCfg, log, agreementId, owner, token, creatorTaskId) {
Function agreementBill
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
async function agreementBill({ log, params }) {
const { agreement: id, username: owner, subscriptionInterval } = params;
const { amqp } = this;
log.debug('billing %s on %s', owner, id);
- 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 calculateDiscounts
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function calculateDiscounts(subscription, customSetupFee, skipSetupFee, trialDiscount, trialCycle) {
Function syncTransactions
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
async function syncTransactions(dispatch, agreementId, owner, start, end) {
Function agreementState
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
async function agreementState({ params: message }) {
const { config, redis, amqp, log } = this;
const { agreement: agreementId, state: action } = message;
const note = message.note || `Applying '${action}' operation to agreement`;
- 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 performSync
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
async function performSync(ctx, { log }) {
const { agreements, txIds } = await getUpdatedTransactions(ctx);
// done - nothing to sync
if (agreements.size === 0) {
- 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 transactionSync
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function transactionSync({ params: message = {} }) {
const { config, redis } = this;
const { paypal: paypalConfig } = config;
function updateCommon(sale, owner) {
- 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 getPendingAgreements
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
async function getPendingAgreements(ctx, query, opts = {}) {
const { service, pulledUsers, missingUsers, pendingAgreements, agreementOwners } = ctx;
const offset = opts.cursor || 0;
const response = await service.dispatch('agreement.list', {
- 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 calculateDiscounts
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function calculateDiscounts(subscription, customSetupFee, skipSetupFee, trialDiscount, trialCycle) {
const regularPayment = { ...subscription.definition.amount };
const setupFee = { ...regularPayment };
const extractCycle = skipSetupFee ? 0 : 1;
const normalizedTrialCycle = subscription.name === 'year'
- 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 createSaveToRedis
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function createSaveToRedis(redis, message) {
return function saveToRedis(data) {
const { plan, plans } = data;
const { meta, level, title } = message;
const aliasedId = message.alias || plan.id;
- 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 updateRedis
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function updateRedis(sale) {
const { redis } = this;
const { state } = sale;
if (state !== 'approved') {
- 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"