enclose-io/compiler

View on GitHub
lts/lib/internal/child_process.js

Summary

Maintainability
F
1 wk
Test Coverage

Function setupChannel has a Cognitive Complexity of 110 (exceeds 5 allowed). Consider refactoring.
Open

function setupChannel(target, channel, serializationMode) {
  target.channel = channel;

  // _channel can be deprecated in version 8
  ObjectDefineProperty(target, '_channel', {
Severity: Minor
Found in lts/lib/internal/child_process.js - About 2 days 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

File child_process.js has 764 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';

const {
  ArrayIsArray,
  ObjectDefineProperty,
Severity: Major
Found in lts/lib/internal/child_process.js - About 1 day to fix

    Function setupChannel has 254 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function setupChannel(target, channel, serializationMode) {
      target.channel = channel;
    
      // _channel can be deprecated in version 8
      ObjectDefineProperty(target, '_channel', {
    Severity: Major
    Found in lts/lib/internal/child_process.js - About 1 day to fix

      Function spawn has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
      Open

      ChildProcess.prototype.spawn = function(options) {
        let i = 0;
      
        if (options === null || typeof options !== 'object') {
          throw new ERR_INVALID_ARG_TYPE('options', 'Object', options);
      Severity: Minor
      Found in lts/lib/internal/child_process.js - About 6 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 _send has 96 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        target._send = function(message, handle, options, callback) {
          assert(this.connected || this.channel);
      
          if (message === undefined)
            throw new ERR_MISSING_ARGS('message');
      Severity: Major
      Found in lts/lib/internal/child_process.js - About 3 hrs to fix

        Function spawn has 94 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        ChildProcess.prototype.spawn = function(options) {
          let i = 0;
        
          if (options === null || typeof options !== 'object') {
            throw new ERR_INVALID_ARG_TYPE('options', 'Object', options);
        Severity: Major
        Found in lts/lib/internal/child_process.js - About 3 hrs to fix

          Function getValidStdio has 77 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function getValidStdio(stdio, sync) {
            let ipc;
            let ipcFd;
          
            // Replace shortcut with an array
          Severity: Major
          Found in lts/lib/internal/child_process.js - About 3 hrs to fix

            Function send has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

                send(message, socket, options) {
                  if (!socket._handle)
                    return;
            
                  // If the socket was created by net.Server
            Severity: Minor
            Found in lts/lib/internal/child_process.js - About 2 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 ChildProcess has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

            function ChildProcess() {
              EventEmitter.call(this);
            
              this._closesNeeded = 1;
              this._closesGot = 0;
            Severity: Minor
            Found in lts/lib/internal/child_process.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

            Function ChildProcess has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function ChildProcess() {
              EventEmitter.call(this);
            
              this._closesNeeded = 1;
              this._closesGot = 0;
            Severity: Minor
            Found in lts/lib/internal/child_process.js - About 1 hr to fix

              Function kill has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

              ChildProcess.prototype.kill = function(sig) {
              
                const signal = sig === 0 ? sig :
                  convertToValidSignal(sig === undefined ? 'SIGTERM' : sig);
              
              
              Severity: Minor
              Found in lts/lib/internal/child_process.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

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

                channel.onread = function(arrayBuffer) {
                  const recvHandle = channel.pendingHandle;
                  channel.pendingHandle = null;
                  if (arrayBuffer) {
                    const nread = streamBaseState[kReadBytesOrError];
              Severity: Minor
              Found in lts/lib/internal/child_process.js - About 1 hr to fix

                Function send has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    send(message, socket, options) {
                      if (!socket._handle)
                        return;
                
                      // If the socket was created by net.Server
                Severity: Minor
                Found in lts/lib/internal/child_process.js - About 1 hr to fix

                  Function postSend has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      postSend(message, handle, options, callback, target) {
                  Severity: Minor
                  Found in lts/lib/internal/child_process.js - About 35 mins to fix

                    Function spawnSync has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function spawnSync(opts) {
                      const options = opts.options;
                      const result = spawn_sync.spawn(options);
                    
                      if (result.output && options.encoding && options.encoding !== 'buffer') {
                    Severity: Minor
                    Found in lts/lib/internal/child_process.js - About 35 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

                    Avoid too many return statements within this function.
                    Open

                      return false;
                    Severity: Major
                    Found in lts/lib/internal/child_process.js - About 30 mins to fix

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

                              if (typeof callback === 'function') {
                                process.nextTick(callback, ex);
                              } else {
                                process.nextTick(() => this.emit('error', ex));
                              }
                      Severity: Minor
                      Found in lts/lib/internal/child_process.js and 1 other location - About 50 mins to fix
                      lts/lib/internal/child_process.js on lines 680..684

                      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

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

                          if (typeof callback === 'function') {
                            process.nextTick(callback, ex);
                          } else {
                            process.nextTick(() => this.emit('error', ex));
                          }
                      Severity: Minor
                      Found in lts/lib/internal/child_process.js and 1 other location - About 50 mins to fix
                      lts/lib/internal/child_process.js on lines 807..811

                      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

                        this.stdout = stdio.length >= 2 && stdio[1].socket !== undefined ?
                          stdio[1].socket : null;
                      Severity: Major
                      Found in lts/lib/internal/child_process.js and 2 other locations - About 40 mins to fix
                      lts/lib/internal/child_process.js on lines 449..450
                      lts/lib/internal/child_process.js on lines 453..454

                      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 49.

                      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

                        this.stdin = stdio.length >= 1 && stdio[0].socket !== undefined ?
                          stdio[0].socket : null;
                      Severity: Major
                      Found in lts/lib/internal/child_process.js and 2 other locations - About 40 mins to fix
                      lts/lib/internal/child_process.js on lines 451..452
                      lts/lib/internal/child_process.js on lines 453..454

                      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 49.

                      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

                        this.stderr = stdio.length >= 3 && stdio[2].socket !== undefined ?
                          stdio[2].socket : null;
                      Severity: Major
                      Found in lts/lib/internal/child_process.js and 2 other locations - About 40 mins to fix
                      lts/lib/internal/child_process.js on lines 449..450
                      lts/lib/internal/child_process.js on lines 451..452

                      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 49.

                      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

                      There are no issues that match your filters.

                      Category
                      Status