Showing 35 of 81 total issues
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 computeFromInterval
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
export const computeFromInterval = (attrs: IJobParameters<any>): Date => {
const previousNextRunAt = attrs.nextRunAt || new Date();
log('[%s:%s] computing next run via interval [%s]', attrs.name, attrs._id, attrs.repeatInterval);
const lastRun = dateForTimezone(attrs.lastRunAt || new Date(), attrs.repeatTimezone);
- 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 runJob
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
async runJob() {
const definition = this.agenda.definitions[this.attrs.name];
if (!definition) {
log('[%s:%s] has no definition, can not run', this.attrs.name, this.attrs._id);
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 jobQueueFilling
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private async jobQueueFilling(name: string): Promise<void> {
this.isJobQueueFilling.set(name, true);
try {
// Don't lock because of a limit we have set (lockLimit, etc)
- 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 highlightActiveHash
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function highlightActiveHash(event) {
var oldUrl, oldSubSectionElement;
// check for and remove old hash active state
if (event && event.originalEvent.oldURL) {
- 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 highlightActiveHash
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function highlightActiveHash(event) {
var oldUrl, oldSubSectionElement;
// check for and remove old hash active state
if (event && event.originalEvent.oldURL) {
- 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 highlightActiveHash
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function highlightActiveHash(event) {
var oldUrl, oldSubSectionElement;
// check for and remove old hash active state
if (event && event.originalEvent.oldURL) {
- 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 highlightActiveHash
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function highlightActiveHash(event) {
var oldUrl, oldSubSectionElement;
// check for and remove old hash active state
if (event && event.originalEvent.oldURL) {
- 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 highlightActiveHash
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function highlightActiveHash(event) {
var oldUrl, oldSubSectionElement;
// check for and remove old hash active state
if (event && event.originalEvent.oldURL) {
- 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 highlightActiveHash
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function highlightActiveHash(event) {
var oldUrl, oldSubSectionElement;
// check for and remove old hash active state
if (event && event.originalEvent.oldURL) {
- 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 toJson
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
toJson(): IJobParameters {
const result = {} as IJobParameters;
for (const key of Object.keys(this.attrs)) {
if (Object.hasOwnProperty.call(this.attrs, key)) {
- 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
Avoid too many return
statements within this function. Open
return;
Function run
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
async run(): Promise<void> {
this.attrs.lastRunAt = new Date();
log(
'[%s:%s] setting lastRunAt to: %s',
this.attrs.name,
- 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"