adobe/brackets

View on GitHub
src/extensions/default/AutoUpdate/node/AutoUpdateDomain.js

Summary

Maintainability
D
2 days
Test Coverage

File AutoUpdateDomain.js has 367 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
 * Copyright (c) 2018 - present Adobe Systems Incorporated. All rights reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
Severity: Minor
Found in src/extensions/default/AutoUpdate/node/AutoUpdateDomain.js - About 4 hrs to fix

    Function downloadInstaller has 51 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function downloadInstaller(requester, isInitialAttempt, updateParams) {
            updateParams = updateParams || _updateParams;
            var currentRequester = requester || "";
            try {
                var ext = path.extname(updateParams.installerName);
    Severity: Major
    Found in src/extensions/default/AutoUpdate/node/AutoUpdateDomain.js - About 2 hrs to fix

      Function performCleanup has 48 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function performCleanup(requester, filesToCache, notifyBack) {
              var currentRequester = requester || "";
              function filterFilesAndNotify(files, filesToCacheArr, notifyBackToBrackets) {
                  files.forEach(function (file) {
                      var fileExt = path.extname(path.basename(file));
      Severity: Minor
      Found in src/extensions/default/AutoUpdate/node/AutoUpdateDomain.js - About 1 hr to fix

        Function init has 48 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function init(domainManager) {
                if (!domainManager.hasDomain("AutoUpdate")) {
                    domainManager.registerDomain("AutoUpdate", {
                        major: 0,
                        minor: 1
        Severity: Minor
        Found in src/extensions/default/AutoUpdate/node/AutoUpdateDomain.js - About 1 hr to fix

          Function validateChecksum has 46 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              function validateChecksum(requester, params) {
                  params = params || {
                      filePath: installerPath,
                      expectedChecksum: _updateParams.checksum
                  };
          Severity: Minor
          Found in src/extensions/default/AutoUpdate/node/AutoUpdateDomain.js - About 1 hr to fix

            Function checkInstallerStatus has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                function checkInstallerStatus(requester, searchParams) {
                    var installErrorStr = searchParams.installErrorStr,
                        bracketsErrorStr = searchParams.bracketsErrorStr,
                        updateDirectory = searchParams.updateDir,
                        encoding =        searchParams.encoding || "utf8",
            Severity: Minor
            Found in src/extensions/default/AutoUpdate/node/AutoUpdateDomain.js - About 1 hr to fix

              Function parseInstallerLog has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  function parseInstallerLog(filepath, searchstring, encoding, callback) {
                      var line = "";
                      var searchFn = function searchFn(str) {
                          var arr = str.split('\n'),
                              lineNum,
              Severity: Minor
              Found in src/extensions/default/AutoUpdate/node/AutoUpdateDomain.js - About 1 hr to fix

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

                    function getFunctionArgs(args) {
                        if (args.length > 2) {
                            var fnArgs = new Array(args.length - 2),
                                i;
                            for (i = 2; i < args.length; ++i) {
                Severity: Major
                Found in src/extensions/default/AutoUpdate/node/AutoUpdateDomain.js and 1 other location - About 3 hrs to fix
                src/extensions/default/AutoUpdate/main.js on lines 167..178

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

                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

                        try {
                            var ext = path.extname(updateParams.installerName);
                            var localInstallerPath = path.resolve(updateDir, Date.now().toString() + ext),
                                localInstallerFile = fs.createWriteStream(localInstallerPath),
                                requestCompleted = true,
                Severity: Minor
                Found in src/extensions/default/AutoUpdate/node/AutoUpdateDomain.js and 1 other location - About 35 mins to fix
                src/extensions/default/AutoUpdate/node/AutoUpdateDomain.js on lines 309..316

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

                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

                                        try {
                                            fs.renameSync(localInstallerPath, installerPath);
                                            postMessageToBrackets(MessageIds.NOTIFY_DOWNLOAD_SUCCESS, currentRequester);
                                        } catch (e) {
                                            console.log("AutoUpdate : Download failed. Exception occurred : " + e.toString());
                Severity: Minor
                Found in src/extensions/default/AutoUpdate/node/AutoUpdateDomain.js and 1 other location - About 35 mins to fix
                src/extensions/default/AutoUpdate/node/AutoUpdateDomain.js on lines 275..323

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

                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

                        fs.stat(updateDir)
                            .then(function (stats) {
                                if (stats) {
                                    if (filesToCache) {
                                        fs.readdir(updateDir)
                Severity: Minor
                Found in src/extensions/default/AutoUpdate/node/AutoUpdateDomain.js and 2 other locations - About 35 mins to fix
                src/extensions/default/AutoUpdate/node/AutoUpdateDomain.js on lines 355..363
                src/extensions/default/AutoUpdate/node/AutoUpdateDomain.js on lines 365..373

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

                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

                                        fs.readdir(updateDir)
                                            .then(function (files) {
                                                filterFilesAndNotify(files, filesToCache, notifyBack);
                                            })
                                            .catch(function (err) {
                Severity: Minor
                Found in src/extensions/default/AutoUpdate/node/AutoUpdateDomain.js and 2 other locations - About 35 mins to fix
                src/extensions/default/AutoUpdate/node/AutoUpdateDomain.js on lines 365..373
                src/extensions/default/AutoUpdate/node/AutoUpdateDomain.js on lines 351..381

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

                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

                                        fs.remove(updateDir)
                                            .then(function () {
                                                console.log('AutoUpdate : Update Directory in AppData Cleaned: Complete');
                                            })
                                            .catch(function (err) {
                Severity: Minor
                Found in src/extensions/default/AutoUpdate/node/AutoUpdateDomain.js and 2 other locations - About 35 mins to fix
                src/extensions/default/AutoUpdate/node/AutoUpdateDomain.js on lines 355..363
                src/extensions/default/AutoUpdate/node/AutoUpdateDomain.js on lines 351..381

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

                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