thomasdondorf/puppeteer-cluster

View on GitHub

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';
Severity: Minor
Found in src/Cluster.ts - About 6 hrs to fix

    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());
                }
    Severity: Minor
    Found in src/Cluster.ts - About 4 hrs to fix

    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());
                }
    Severity: Major
    Found in src/Cluster.ts - About 3 hrs to fix

      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> {
      Severity: Major
      Found in src/Worker.ts - About 2 hrs to fix

        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;
        Severity: Minor
        Found in src/Cluster.ts - About 1 hr to fix

          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
          Severity: Minor
          Found in src/Cluster.ts - About 1 hr to fix

          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
          Severity: Minor
          Found in src/Cluster.ts - About 1 hr to fix

            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;
            Severity: Minor
            Found in src/concurrency/built-in/Browser.ts - About 1 hr to fix

              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();
              Severity: Minor
              Found in src/Cluster.ts - About 1 hr to fix

                Function workerInstance has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public async workerInstance() {
                        let resources: ResourceData;
                
                        return {
                            jobInstance: async () => {
                Severity: Minor
                Found in src/concurrency/SingleBrowserImplementation.ts - About 1 hr to fix

                  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();
                  
                  
                  Severity: Minor
                  Found in src/SystemMonitor.ts - About 1 hr to fix

                    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> {
                    Severity: Minor
                    Found in src/Worker.ts - About 1 hr to fix

                    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;
                    Severity: Major
                    Found in src/Cluster.ts - About 30 mins to fix

                      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;
                      Severity: Minor
                      Found in src/Cluster.ts - About 25 mins to fix

                      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();
                      
                      
                      Severity: Minor
                      Found in src/SystemMonitor.ts - About 25 mins to fix

                      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

                      Severity
                      Category
                      Status
                      Source
                      Language