Showing 15 of 15 total issues
File Cluster.ts
has 428 lines of code (exceeds 250 allowed). Consider refactoring. Open
import Job, { ExecuteResolve, ExecuteReject, ExecuteCallbacks } from './Job';
import Display from './Display';
import * as util from './util';
import Worker, { WorkResult } from './Worker';
Function doWork
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
private async doWork() {
if (this.jobQueue.size() === 0) { // no jobs available
if (this.workersBusy.length === 0) {
this.idleResolvers.forEach(resolve => resolve());
}
- 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 doWork
has 91 lines of code (exceeds 25 allowed). Consider refactoring. Open
private async doWork() {
if (this.jobQueue.size() === 0) { // no jobs available
if (this.workersBusy.length === 0) {
this.idleResolvers.forEach(resolve => resolve());
}
Function handle
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
public async handle(
task: TaskFunction<JobData, ReturnData>,
job: Job<JobData, ReturnData>,
timeout: number,
): Promise<WorkResult> {
Function monitor
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
private monitor(): void {
if (!this.display) {
this.display = new Display();
}
const display = this.display;
Function init
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
private async init() {
const browserOptions = this.options.puppeteerOptions;
let puppeteer = this.options.puppeteer;
if (this.options.puppeteer == null) { // check for null or 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 init
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
private async init() {
const browserOptions = this.options.puppeteerOptions;
let puppeteer = this.options.puppeteer;
if (this.options.puppeteer == null) { // check for null or undefined
Function workerInstance
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public async workerInstance(perBrowserOptions: puppeteer.LaunchOptions | undefined):
Promise<WorkerInstance> {
const options = perBrowserOptions || this.options;
let chrome = await this.puppeteer.launch(options) as puppeteer.Browser;
Function launchWorker
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
private async launchWorker() {
// signal, that we are starting a worker
this.workersStarting += 1;
this.nextWorkerId += 1;
this.lastLaunchedWorkerTime = Date.now();
Function workerInstance
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public async workerInstance() {
let resources: ResourceData;
return {
jobInstance: async () => {
Function calcLoad
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
private calcLoad() { // based on https://gist.github.com/bag-man/5570809
let totalIdle = 0;
let totalTick = 0;
const cpus = os.cpus();
Function handle
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public async handle(
task: TaskFunction<JobData, ReturnData>,
job: Job<JobData, ReturnData>,
timeout: number,
): Promise<WorkResult> {
- 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 monitor
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private monitor(): void {
if (!this.display) {
this.display = new Display();
}
const display = this.display;
- 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 calcLoad
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private calcLoad() { // based on https://gist.github.com/bag-man/5570809
let totalIdle = 0;
let totalTick = 0;
const cpus = os.cpus();
- 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"