cdnjs/autoupdate

View on GitHub
updaters/npm.js

Summary

Maintainability
C
7 hrs
Test Coverage

Function processNewVersion has 79 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var processNewVersion = function (pkg, version) {
  var npmName = pkg.autoupdate.target;

  // sometimes the tar is extracted to a dir that isnt called 'package' - get that dir via glob
  var extractLibPath = glob.sync(getPackageTempPath(pkg, version) + '/*/')[0];
Severity: Major
Found in updaters/npm.js - About 3 hrs to fix

    Function updateLibraryVersion has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    var updateLibraryVersion = function(library, tarballUrl, version, cb) {
      var npmName = library.autoupdate.target;
      if (invalidNpmName(library.name)) {
        return cb(error(npmName + " has a malicious package name:" + library.name, error.PKG_NAME));
      }
    Severity: Minor
    Found in updaters/npm.js - About 1 hr to fix

      Function update has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      var update = function(library, callback) {
        var msg;
      
        var target = library.autoupdate.target;
        if (!isValidFileMap(library)) {
      Severity: Minor
      Found in updaters/npm.js - About 1 hr to fix

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

        var processNewVersion = function (pkg, version) {
          var npmName = pkg.autoupdate.target;
        
          // sometimes the tar is extracted to a dir that isnt called 'package' - get that dir via glob
          var extractLibPath = glob.sync(getPackageTempPath(pkg, version) + '/*/')[0];
        Severity: Minor
        Found in updaters/npm.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 parse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        var parse = function(jsonFile, ignoreMissing, ignoreParseFail) {
          var content;
        
          try {
            content = fs.readFileSync(jsonFile, 'utf8');
        Severity: Minor
        Found in updaters/npm.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