deps/npm/lib/ls.js

Summary

Maintainability
F
4 days
Test Coverage

Function makeArchy_ has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

function makeArchy_ (data, long, dir, depth, parent, d) {
  if (typeof data === "string") {
    if (depth -1 <= npm.config.get("depth")) {
      // just missing
      var unmet = "UNMET DEPENDENCY"
Severity: Minor
Found in deps/npm/lib/ls.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 ls.js has 311 lines of code (exceeds 250 allowed). Consider refactoring.
Open


// show the installed versions of packages
//
// --parseable creates output like this:
// <fullpath>:<name@ver>:<realpath>:<flags>
Severity: Minor
Found in deps/npm/lib/ls.js - About 3 hrs to fix

    Function getLite has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

    function getLite (data, noname) {
      var lite = {}
        , maxDepth = npm.config.get("depth")
    
      if (!noname && data.name) lite.name = data.name
    Severity: Minor
    Found in deps/npm/lib/ls.js - About 3 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 makeArchy_ has 63 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function makeArchy_ (data, long, dir, depth, parent, d) {
      if (typeof data === "string") {
        if (depth -1 <= npm.config.get("depth")) {
          // just missing
          var unmet = "UNMET DEPENDENCY"
    Severity: Major
    Found in deps/npm/lib/ls.js - About 2 hrs to fix

      Function makeParseable_ has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

      function makeParseable_ (data, long, dir, depth, parent, d) {
        if (data.hasOwnProperty("_found") && data._found !== true) return ""
      
        if (typeof data === "string") {
          if (data.depth < npm.config.get("depth")) {
      Severity: Minor
      Found in deps/npm/lib/ls.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 getLite has 58 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function getLite (data, noname) {
        var lite = {}
          , maxDepth = npm.config.get("depth")
      
        if (!noname && data.name) lite.name = data.name
      Severity: Major
      Found in deps/npm/lib/ls.js - About 2 hrs to fix

        Function ls has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

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

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

          function makeParseable (data, long, dir, depth, parent, d) {
          Severity: Minor
          Found in deps/npm/lib/ls.js - About 45 mins to fix

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

            function makeParseable_ (data, long, dir, depth, parent, d) {
            Severity: Minor
            Found in deps/npm/lib/ls.js - About 45 mins to fix

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

              function makeArchy_ (data, long, dir, depth, parent, d) {
              Severity: Minor
              Found in deps/npm/lib/ls.js - About 45 mins to fix

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

                function getExtras (data) {
                  var extras = []
                
                  if (data.description) extras.push(data.description)
                  if (data.repository) extras.push(data.repository.url)
                Severity: Minor
                Found in deps/npm/lib/ls.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 bfsify has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                function bfsify (root, args, current, queue, seen) {
                Severity: Minor
                Found in deps/npm/lib/ls.js - About 35 mins to fix

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

                  function pruneNestedExtraneous (data, visited) {
                    visited = visited || []
                    visited.push(data)
                    for (var i in data.dependencies) {
                      if (data.dependencies[i].extraneous) {
                  Severity: Minor
                  Found in deps/npm/lib/ls.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 3 locations. Consider refactoring.
                  Open

                    if (data.invalid) {
                      lite.invalid = true
                      lite.problems = lite.problems || []
                      lite.problems.push( "invalid: "
                                        + data.name + "@" + data.version
                  Severity: Major
                  Found in deps/npm/lib/ls.js and 2 other locations - About 2 hrs to fix
                  deps/npm/lib/ls.js on lines 120..126
                  deps/npm/lib/ls.js on lines 142..148

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

                  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

                    if (data.extraneous) {
                      lite.extraneous = true
                      lite.problems = lite.problems || []
                      lite.problems.push( "extraneous: "
                                        + data.name + "@" + data.version
                  Severity: Major
                  Found in deps/npm/lib/ls.js and 2 other locations - About 2 hrs to fix
                  deps/npm/lib/ls.js on lines 134..140
                  deps/npm/lib/ls.js on lines 142..148

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

                  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

                    if (data.peerInvalid) {
                      lite.peerInvalid = true
                      lite.problems = lite.problems || []
                      lite.problems.push( "peer invalid: "
                                        + data.name + "@" + data.version
                  Severity: Major
                  Found in deps/npm/lib/ls.js and 2 other locations - About 2 hrs to fix
                  deps/npm/lib/ls.js on lines 120..126
                  deps/npm/lib/ls.js on lines 134..140

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

                  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

                      out.nodes = Object.keys(data.dependencies || {})
                        .sort(alphasort).map(function (d) {
                          return makeArchy_(data.dependencies[d], long, dir, depth + 1, data, d)
                        })
                  Severity: Major
                  Found in deps/npm/lib/ls.js and 1 other location - About 1 hr to fix
                  deps/npm/lib/ls.js on lines 349..352

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

                  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

                    .concat(Object.keys(data.dependencies || {})
                      .sort(alphasort).map(function (d) {
                        return makeParseable(data.dependencies[d], long, dir, depth + 1, data, d)
                      }))
                  Severity: Major
                  Found in deps/npm/lib/ls.js and 1 other location - About 1 hr to fix
                  deps/npm/lib/ls.js on lines 314..317

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

                  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 (data.peerInvalid) {
                      var peerInvalid = "peer invalid"
                      if (npm.color) peerInvalid = color.bgBlack(color.red(peerInvalid))
                      out.label += " " + peerInvalid
                    }
                  Severity: Major
                  Found in deps/npm/lib/ls.js and 1 other location - About 1 hr to fix
                  deps/npm/lib/ls.js on lines 288..292

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

                  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 (data.extraneous && data.path !== dir) {
                      var extraneous = "extraneous"
                      if (npm.color) extraneous = color.bgBlack(color.green(extraneous))
                      out.label += " " + extraneous
                    }
                  Severity: Major
                  Found in deps/npm/lib/ls.js and 1 other location - About 1 hr to fix
                  deps/npm/lib/ls.js on lines 282..286

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

                  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