cdnjs/autoupdate

View on GitHub

Showing 8 of 8 total issues

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

var update = function (library, callback) {
  var target = library.autoupdate.target;
  var localTarget = path.normalize(path.join(
    __dirname, '../', GIT_REPO_LOCAL_FOLDER, library.name
  ));
Severity: Major
Found in updaters/git.js - About 5 hrs to fix

    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 initialize has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          var initialize = function (err) {
            if (err) {
              console.error('Got an error: ' + err);
            } else {
              console.log('Starting Auto Update'.cyan);
          Severity: Minor
          Found in autoupdate.js - About 1 hr to fix

            Consider simplifying this complex logical expression.
            Open

                          if (
                            (allFiles.length !== 0) &&
                            (
                              (!library.version) ||
                              (
            Severity: Major
            Found in updaters/git.js - About 40 mins to fix

              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

              Severity
              Category
              Status
              Source
              Language