icodeforlove/task.js

View on GitHub

Showing 17 of 17 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

parentPort.on('message', (message) => {
    let args = Object.keys(message).filter(function (key) {
        return key.match(/^argument/);
    }).sort(function (a, b) {
        return parseInt(a.slice(8), 10) - parseInt(b.slice(8), 10);
Severity: Major
Found in src/server/WorkerThreadWorker.js and 1 other location - About 1 day to fix
src/server/EvalWorker.js on lines 1..25

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 341.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

process.on('message', (message) => {
    let args = Object.keys(message).filter(function (key) {
        return key.match(/^argument/);
    }).sort(function (a, b) {
        return parseInt(a.slice(8), 10) - parseInt(b.slice(8), 10);
Severity: Major
Found in src/server/EvalWorker.js and 1 other location - About 1 day to fix
src/server/WorkerThreadWorker.js on lines 3..27

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 341.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

File WorkerManager.js has 329 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class Transferables {
    constructor (transferables) {
        this.transferables = transferables.map(transferable => {
            if (!(transferable instanceof ArrayBuffer) && transferable && transferable.buffer instanceof ArrayBuffer) {
                return transferable.buffer;
Severity: Minor
Found in src/WorkerManager.js - About 3 hrs to fix

    Function constructor has 61 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        constructor ($config, WorkerProxies) {
            $config = $config || {};
    
            this.id = ++WorkerManager.managerCount;
    
    
    Severity: Major
    Found in src/WorkerManager.js - About 2 hrs to fix

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

          postMessage = (message, transferables) => {
              if (this._debug) {
                  this._log({
                      taskId: message.id,
                      action: 'send_task_to_actual_worker',
      Severity: Major
      Found in src/server/NodeWorkerThread.js and 1 other location - About 2 hrs to fix
      src/client/WebWorker.js on lines 60..69

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 83.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

          postMessage = (message, transferables) => {
              if (this._debug) {
                  this._log({
                      taskId: message.id,
                      action: 'send_task_to_actual_worker',
      Severity: Major
      Found in src/client/WebWorker.js and 1 other location - About 2 hrs to fix
      src/server/NodeWorkerThread.js on lines 69..79

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 83.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Function _createWorker has 56 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          _createWorker () {
              let workerId = ++this._totalWorkersCreated;
      
              let worker = new this._WorkerProxy({
                  debug: this._debug,
      Severity: Major
      Found in src/WorkerManager.js - About 2 hrs to fix

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

            _onExit = () => {
                if (!this._alive) {
                    return;
                }
        
        
        Severity: Major
        Found in src/server/NodeWorkerThread.js and 1 other location - About 1 hr to fix
        src/server/NodeWorker.js on lines 46..60

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 73.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

            _onExit = () => {
                if (!this._alive) {
                    return;
                }
        
        
        Severity: Major
        Found in src/server/NodeWorker.js and 1 other location - About 1 hr to fix
        src/server/NodeWorkerThread.js on lines 49..63

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 73.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Function _run has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            _run (task) {
                if (this._terminated) {
                    return;
                }
        
        
        Severity: Minor
        Found in src/WorkerManager.js - About 1 hr to fix

          Function _run has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              _run (task) {
                  if (this._terminated) {
                      return;
                  }
          
          
          Severity: Minor
          Found in src/WorkerManager.js - 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

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

              terminate = () => {
                  if (this._debug) {
                      this._log({
                          action: 'terminated'
                      });
          Severity: Major
          Found in src/server/NodeWorkerThread.js and 2 other locations - About 50 mins to fix
          src/client/WebWorker.js on lines 71..78
          src/server/NodeWorker.js on lines 77..84

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 52.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

              terminate = () => {
                  if (this._debug) {
                      this._log({
                          action: 'terminated'
                      });
          Severity: Major
          Found in src/server/NodeWorker.js and 2 other locations - About 50 mins to fix
          src/client/WebWorker.js on lines 71..78
          src/server/NodeWorkerThread.js on lines 81..89

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 52.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

              terminate = () => {
                  if (this._debug) {
                      this._log({
                          message: 'terminated'
                      });
          Severity: Major
          Found in src/client/WebWorker.js and 2 other locations - About 50 mins to fix
          src/server/NodeWorker.js on lines 77..84
          src/server/NodeWorkerThread.js on lines 81..89

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 52.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Function constructor has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              constructor ($config, WorkerProxies) {
                  $config = $config || {};
          
                  this.id = ++WorkerManager.managerCount;
          
          
          Severity: Minor
          Found in src/WorkerManager.js - About 45 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 _createWorker has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              _createWorker () {
                  let workerId = ++this._totalWorkersCreated;
          
                  let worker = new this._WorkerProxy({
                      debug: this._debug,
          Severity: Minor
          Found in src/WorkerManager.js - About 45 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

          Consider simplifying this complex logical expression.
          Open

                  if (this._globalsInitializationFunction || this._globals || this._requires) {
                      if (this._debug) {
                          this._log({
                              action: 'run_global_initialize',
                              message: `running global initialization code`
          Severity: Major
          Found in src/WorkerManager.js - About 40 mins to fix
            Severity
            Category
            Status
            Source
            Language