deps/npm/lib/utils/lifecycle.js

Summary

Maintainability
D
2 days
Test Coverage

Function makeEnv has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

function makeEnv (data, prefix, env) {
  prefix = prefix || "npm_package_"
  if (!env) {
    env = {}
    for (var i in process.env) if (!i.match(/^npm_/)) {
Severity: Minor
Found in deps/npm/lib/utils/lifecycle.js - About 5 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

File lifecycle.js has 295 lines of code (exceeds 250 allowed). Consider refactoring.
Open

exports = module.exports = lifecycle
exports.cmd = cmd
exports.makeEnv = makeEnv

var log = require("npmlog")
Severity: Minor
Found in deps/npm/lib/utils/lifecycle.js - About 3 hrs to fix

    Function makeEnv has 74 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function makeEnv (data, prefix, env) {
      prefix = prefix || "npm_package_"
      if (!env) {
        env = {}
        for (var i in process.env) if (!i.match(/^npm_/)) {
    Severity: Major
    Found in deps/npm/lib/utils/lifecycle.js - About 2 hrs to fix

      Function runCmd_ has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function runCmd_ (cmd, pkg, env, wd, stage, unsafe, uid, gid, cb_) {
      
        function cb (er) {
          cb_.apply(null, arguments)
          log.resume()
      Severity: Major
      Found in deps/npm/lib/utils/lifecycle.js - About 2 hrs to fix

        Function lifecycle_ has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function lifecycle_ (pkg, stage, wd, env, unsafe, failOk, cb) {
          var pathArr = []
            , p = wd.split("node_modules")
            , acc = path.resolve(p.shift())
        
        
        Severity: Minor
        Found in deps/npm/lib/utils/lifecycle.js - About 1 hr to fix

          Function runCmd_ has 9 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          function runCmd_ (cmd, pkg, env, wd, stage, unsafe, uid, gid, cb_) {
          Severity: Major
          Found in deps/npm/lib/utils/lifecycle.js - About 1 hr to fix

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

            function runCmd_ (cmd, pkg, env, wd, stage, unsafe, uid, gid, cb_) {
            
              function cb (er) {
                cb_.apply(null, arguments)
                log.resume()
            Severity: Minor
            Found in deps/npm/lib/utils/lifecycle.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 lifecycle_ has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

            function lifecycle_ (pkg, stage, wd, env, unsafe, failOk, cb) {
              var pathArr = []
                , p = wd.split("node_modules")
                , acc = path.resolve(p.shift())
            
            
            Severity: Minor
            Found in deps/npm/lib/utils/lifecycle.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 runCmd has 8 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            function runCmd (note, cmd, pkg, env, stage, wd, unsafe, cb) {
            Severity: Major
            Found in deps/npm/lib/utils/lifecycle.js - About 1 hr to fix

              Function runCmd has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

              function runCmd (note, cmd, pkg, env, stage, wd, unsafe, cb) {
                if (running) {
                  queue.push([note, cmd, pkg, env, stage, wd, unsafe, cb])
                  return
                }
              Severity: Minor
              Found in deps/npm/lib/utils/lifecycle.js - About 55 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 lifecycle_ has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              function lifecycle_ (pkg, stage, wd, env, unsafe, failOk, cb) {
              Severity: Major
              Found in deps/npm/lib/utils/lifecycle.js - About 50 mins to fix

                Function lifecycle has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                function lifecycle (pkg, stage, wd, unsafe, failOk, cb) {
                Severity: Minor
                Found in deps/npm/lib/utils/lifecycle.js - About 45 mins to fix

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

                  function lifecycle (pkg, stage, wd, unsafe, failOk, cb) {
                    if (typeof cb !== "function") cb = failOk, failOk = false
                    if (typeof cb !== "function") cb = unsafe, unsafe = false
                    if (typeof cb !== "function") cb = wd, wd = null
                  
                  
                  Severity: Minor
                  Found in deps/npm/lib/utils/lifecycle.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 runPackageLifecycle has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  function runPackageLifecycle (pkg, env, wd, unsafe, cb) {
                  Severity: Minor
                  Found in deps/npm/lib/utils/lifecycle.js - About 35 mins to fix

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

                    function runHookLifecycle (pkg, env, wd, unsafe, cb) {
                    Severity: Minor
                    Found in deps/npm/lib/utils/lifecycle.js - About 35 mins to fix

                      There are no issues that match your filters.

                      Category
                      Status