Showing 11 of 13 total issues
Function _dispatch
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
async _dispatch () {
// to go or not to go
if (this.queue.size() <= 0) {
debug(this.name, "queue is empty");
- 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
File index.js
has 315 lines of code (exceeds 250 allowed). Consider refactoring. Open
"use strict";
const { EventEmitter } = require("events");
const { validate: validateUUID } = require("uuid");
const debug = require("debug")("sbs:sbs");
const Queue = require("./fifo");
Function _dispatch
has 81 lines of code (exceeds 25 allowed). Consider refactoring. Open
async _dispatch () {
// to go or not to go
if (this.queue.size() <= 0) {
debug(this.name, "queue is empty");
Function constructor
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor (opt = {}) {
super();
this.maxConcurrent = sanitizeNumber(opt.maxConcurrent, 1, null, 1);
this.exec = typeof opt.exec === "function" ? opt.exec : null;
this.retry = opt.retry;
Function _qsub
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
_qsub (job, urgent) {
if (typeof this.exec !== "function" && typeof job !== "function" && typeof job.exec !== "function") {
debug(this.name, "no function specified");
return null;
}
Function sanitizeNumber
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function sanitizeNumber (num, min, max, def) {
let rt = def;
if (typeof num === "string") {
rt = parseFloat(num);
}
- 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 qsub
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
qsub (job, urgent = false) {
if (this.submitHook) {
const rt = this.submitHook(this.queue, job, urgent);
if (rt instanceof Promise || (rt && typeof rt.then === "function")) {
// submitHook is async, _qsub() will be called after submitHook() is fullfilled
- 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 getResult
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
getResult (id, keepResult) {
let rt = null;
if (this.failed.has(id)) {
rt = this.failed.get(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 _qsub
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
_qsub (job, urgent) {
if (typeof this.exec !== "function" && typeof job !== "function" && typeof job.exec !== "function") {
debug(this.name, "no function specified");
return 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 clear
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
clear () {
this.stop();
this.queue.clear();
this.finished.clear();
this.failed.clear();
- 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 constructor
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
constructor (opt = {}) {
super();
this.maxConcurrent = sanitizeNumber(opt.maxConcurrent, 1, null, 1);
this.exec = typeof opt.exec === "function" ? opt.exec : null;
this.retry = opt.retry;
- 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"