Function saveJob
has 84 lines of code (exceeds 25 allowed). Consider refactoring. Open
async saveJob<DATA = unknown | void>(job: Job<DATA>): Promise<Job<DATA>> {
try {
log('attempting to save a job');
// Grab information needed to save job but that we don't want to persist in MongoDB
File JobDbRepository.ts
has 297 lines of code (exceeds 250 allowed). Consider refactoring. Open
import * as debug from 'debug';
import {
Collection,
Db,
Filter,
Function saveJob
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
async saveJob<DATA = unknown | void>(job: Job<DATA>): Promise<Job<DATA>> {
try {
log('attempting to save a job');
// Grab information needed to save job but that we don't want to persist in MongoDB
- 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 connect
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
async connect(): Promise<void> {
const db = await this.createConnection();
log('successful connection to MongoDB', db.options);
const collection = this.connectOptions.db?.collection || 'agendaJobs';
Function saveJobState
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
async saveJobState(job: Job<any>): Promise<void> {
const id = job.attrs._id;
const $set = {
lockedAt: (job.attrs.lockedAt && new Date(job.attrs.lockedAt)) || undefined,
nextRunAt: (job.attrs.nextRunAt && new Date(job.attrs.nextRunAt)) || undefined,
- 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 connect
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
async connect(): Promise<void> {
const db = await this.createConnection();
log('successful connection to MongoDB', db.options);
const collection = this.connectOptions.db?.collection || 'agendaJobs';
- 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"