deps/npm/lib/cache/add-named.js

Summary

Maintainability
C
1 day
Test Coverage

Function addNameVersion has 68 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function addNameVersion (name, v, data, cb) {
  var ver = semver.valid(v, true)
  if (!ver) return cb(new Error("Invalid version: "+v))

  var response
Severity: Major
Found in deps/npm/lib/cache/add-named.js - About 2 hrs to fix

    Function addNameVersion has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    function addNameVersion (name, v, data, cb) {
      var ver = semver.valid(v, true)
      if (!ver) return cb(new Error("Invalid version: "+v))
    
      var response
    Severity: Minor
    Found in deps/npm/lib/cache/add-named.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 next has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      function next () {
        deprCheck(data)
        var dist = data.dist
    
        if (!dist) return cb(new Error("No dist in "+data._id+" package"))
    Severity: Minor
    Found in deps/npm/lib/cache/add-named.js - About 1 hr to fix

      Function addNameRange has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      function addNameRange (name, range, data, cb) {
        range = semver.validRange(range, true)
        if (range === null) return cb(new Error(
          "Invalid version range: " + range
        ))
      Severity: Minor
      Found in deps/npm/lib/cache/add-named.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 addNameRange has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function addNameRange (name, range, data, cb) {
        range = semver.validRange(range, true)
        if (range === null) return cb(new Error(
          "Invalid version range: " + range
        ))
      Severity: Minor
      Found in deps/npm/lib/cache/add-named.js - About 1 hr to fix

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

        function addNameTag (name, tag, data, cb) {
          log.info("addNameTag", [name, tag])
          var explicit = true
          if (!tag) {
            explicit = false
        Severity: Minor
        Found in deps/npm/lib/cache/add-named.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

        Avoid too many return statements within this function.
        Open

                  if (er) return fetchit()
        Severity: Major
        Found in deps/npm/lib/cache/add-named.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                      else return cb(null, data)
          Severity: Major
          Found in deps/npm/lib/cache/add-named.js - About 30 mins to fix

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

            function addNamed (name, version, data, cb_) {
              assert(typeof name === "string", "must have module name")
              assert(typeof cb_ === "function", "must have callback")
            
              var key = name + "@" + version
            Severity: Minor
            Found in deps/npm/lib/cache/add-named.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

            There are no issues that match your filters.

            Category
            Status