deps/npm/lib/outdated.js

Summary

Maintainability
F
3 days
Test Coverage

Function shouldUpdate has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
Open

function shouldUpdate (args, dir, dep, has, req, depth, cb, type) {
  // look up the most recent version.
  // if that's what we already have, or if it's not on the args list,
  // then dive into it.  Otherwise, cb() with the data.

Severity: Minor
Found in deps/npm/lib/outdated.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 outdated_ has 90 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function outdated_ (args, dir, parentHas, depth, cb) {
  // get the deps from package.json, or {<dir/node_modules/*>:"*"}
  // asyncMap over deps:
  //   shouldHave = cache.add(dep, req).version
  //   if has === shouldHave then
Severity: Major
Found in deps/npm/lib/outdated.js - About 3 hrs to fix

    Function shouldUpdate has 82 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function shouldUpdate (args, dir, dep, has, req, depth, cb, type) {
      // look up the most recent version.
      // if that's what we already have, or if it's not on the args list,
      // then dive into it.  Otherwise, cb() with the data.
    
    
    Severity: Major
    Found in deps/npm/lib/outdated.js - About 3 hrs to fix

      File outdated.js has 303 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      /*
      
      npm outdated [pkg]
      
      Does the following:
      Severity: Minor
      Found in deps/npm/lib/outdated.js - About 3 hrs to fix

        Function outdated has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function outdated (args, silent, cb) {
          if (typeof cb !== "function") cb = silent, silent = false
          var dir = path.resolve(npm.dir, "..")
        
          // default depth for `outdated` is 0 (cf. `ls`)
        Severity: Minor
        Found in deps/npm/lib/outdated.js - About 1 hr to fix

          Function updateDeps has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            function updateDeps (er, d) {
              if (er) {
                if (parsed.type !== 'local') return cb()
                return updateLocalDeps()
              }
          Severity: Minor
          Found in deps/npm/lib/outdated.js - About 1 hr to fix

            Function shouldUpdate has 8 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            function shouldUpdate (args, dir, dep, has, req, depth, cb, type) {
            Severity: Major
            Found in deps/npm/lib/outdated.js - About 1 hr to fix

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

              function makePretty (p) {
                var dep = p[1]
                  , dir = path.resolve(p[0], "node_modules", dep)
                  , has = p[2]
                  , want = p[3]
              Severity: Minor
              Found in deps/npm/lib/outdated.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 (!curr || dFromUrl && cFromUrl && d._from !== curr.from
                        || d.version !== curr.version
                        || d.version !== l.version) {
                      if (parsed.type === 'local') return updateLocalDeps(l.version)
              
              
              Severity: Major
              Found in deps/npm/lib/outdated.js - About 40 mins to fix

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

                function outdated_ (args, dir, parentHas, depth, cb) {
                Severity: Minor
                Found in deps/npm/lib/outdated.js - About 35 mins to fix

                  Avoid too many return statements within this function.
                  Open

                          return onCacheAdd(null, d.versions[v])
                  Severity: Major
                  Found in deps/npm/lib/outdated.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                        return next()
                    Severity: Major
                    Found in deps/npm/lib/outdated.js - About 30 mins to fix

                      Function outdated_ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function outdated_ (args, dir, parentHas, depth, cb) {
                        // get the deps from package.json, or {<dir/node_modules/*>:"*"}
                        // asyncMap over deps:
                        //   shouldHave = cache.add(dep, req).version
                        //   if has === shouldHave then
                      Severity: Minor
                      Found in deps/npm/lib/outdated.js - 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

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

                          if (npm.config.get("save-dev")) {
                            deps = d.devDependencies || {}
                            Object.keys(deps).forEach(function (k) {
                              types[k] = "devDependencies"
                            })
                      Severity: Major
                      Found in deps/npm/lib/outdated.js and 1 other location - About 2 hrs to fix
                      deps/npm/lib/outdated.js on lines 209..215

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

                      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

                          if (npm.config.get("save-optional")) {
                            deps = d.optionalDependencies || {}
                            Object.keys(deps).forEach(function (k) {
                              types[k] = "optionalDependencies"
                            })
                      Severity: Major
                      Found in deps/npm/lib/outdated.js and 1 other location - About 2 hrs to fix
                      deps/npm/lib/outdated.js on lines 192..199

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

                      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

                          var dep = p[1]
                            , dir = path.resolve(p[0], "node_modules", dep)
                            , has = p[2]
                            , want = p[3]
                            , latest = p[4]
                      Severity: Major
                      Found in deps/npm/lib/outdated.js and 1 other location - About 1 hr to fix
                      deps/npm/lib/outdated.js on lines 89..94

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

                      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

                        var dep = p[1]
                          , dir = path.resolve(p[0], "node_modules", dep)
                          , has = p[2]
                          , want = p[3]
                          , latest = p[4]
                      Severity: Major
                      Found in deps/npm/lib/outdated.js and 1 other location - About 1 hr to fix
                      deps/npm/lib/outdated.js on lines 133..138

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

                      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