juanmard/icestudio

View on GitHub
services/tools.js

Summary

Maintainability
F
1 wk
Test Coverage

File tools.js has 956 lines of code (exceeds 250 allowed). Consider refactoring.
Open

angular
  .module('icestudio')
  .service(
    'tools',
    function (
Severity: Major
Found in services/tools.js - About 2 days to fix

    Function processResult has 310 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          function processResult(result, code) {
            result = result || {};
            var _error = result.error;
            var stdout = result.stdout;
            var stderr = result.stderr;
    Severity: Major
    Found in services/tools.js - About 1 day to fix

      Function addCollections has 78 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            this.addCollections = function (filepaths) {
              // Load zip file
              async.eachSeries(filepaths, function (filepath, nextzip) {
                //alertify.message(_tcStr('Load {{name}} ...', { name: `<b>${common.basename(filepath)}</b>` }));
                var zipData = nodeAdmZip(filepath);
      Severity: Major
      Found in services/tools.js - About 3 hrs to fix

        Function generateCode has 57 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              function generateCode(cmd) {
                return new Promise(function (resolve) {
                  project.snapshot();
                  project.update();
                  var opt = {
        Severity: Major
        Found in services/tools.js - About 2 hrs to fix

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

                function ICEToolRun(commands, startMessage, endMessage) {
                  return new Promise(function (resolve) {
                    var sourceCode = '';
          
                    if (!taskRunning) {
          Severity: Major
          Found in services/tools.js - About 2 hrs to fix

            Function normalizeCodeError has 45 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  function normalizeCodeError(codeError, modules) {
                    var newCodeError;
                    // Find the module with the error
                    for (var i in modules) {
                      var module = modules[i];
            Severity: Minor
            Found in services/tools.js - About 1 hr to fix

              Function mapCodeModules has 44 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    function mapCodeModules(code) {
                      var codelines = code.split('\n');
                      var match,
                        module = {
                          params: [],
              Severity: Minor
              Found in services/tools.js - About 1 hr to fix

                Function initializePluginManager has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      this.initializePluginManager = function (callbackOnRun) {
                        if (typeof ICEpm !== 'undefined') {
                          console.log('ENV', common);
                          ICEpm.setEnvironment(common);
                          ICEpm.setPluginDir(common.DEFAULT_PLUGIN_DIR, function () {
                Severity: Minor
                Found in services/tools.js - About 1 hr to fix

                  Function installCollection has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                        function installCollection(collection, zip) {
                          var i,
                            dest = '';
                          var pattern = RegExp('^' + collection.origName);
                          for (i in collection.blocks) {
                  Severity: Minor
                  Found in services/tools.js - About 1 hr to fix

                    Function executeLocal has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          function executeLocal(commands) {
                            return new Promise(function (resolve) {
                              var command = common.ICETOOL.concat(commands)
                                .concat(['-p', `"${common.BUILD_DIR}"`])
                                .join(' ');
                    Severity: Minor
                    Found in services/tools.js - About 1 hr to fix

                      Function getCollections has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                            function getCollections(zipData) {
                              var data = '';
                              var _collections = {};
                              var zipEntries = zipData.getEntries();
                      
                      
                      Severity: Minor
                      Found in services/tools.js - About 1 hr to fix

                        Avoid deeply nested control flow statements.
                        Open

                                        for (var j in module.params) {
                                          var param = module.params[j];
                                          if (
                                            codeError.line === param.line ||
                                            (matchConstant && param.name === matchConstant[1])
                        Severity: Major
                        Found in services/tools.js - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                          switch (common.selectedBoard.name) {
                                            // TinyFPGA-B2 programmer errors
                                            case 'TinyFPGA-B2':
                                            case 'TinyFPGA-BX':
                                              var match = stdout.match(/Bootloader\snot\sactive/g);
                          Severity: Major
                          Found in services/tools.js - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                          else if (
                                            stdout.indexOf('Library not loaded:') !== -1 &&
                                            stdout.indexOf('libffi') !== -1
                                          ) {
                                            resultAlert = alertify.error(
                            Severity: Major
                            Found in services/tools.js - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                if (common.selectedBoard.name.startsWith('TinyFPGA-B')) {
                                                  // TinyFPGA bootloader notification
                                                  errorMessage +=
                                                    '</br>(' + _tcStr('Bootloader not active') + ')';
                                                }
                              Severity: Major
                              Found in services/tools.js - About 45 mins to fix

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

                                            } else {
                                              // PCF file
                                              var pcfFile = compiler.generate('pcf', project.get(), opt)[0];
                                              nodeFs.writeFileSync(
                                                nodePath.join(common.BUILD_DIR, pcfFile.name),
                                Severity: Major
                                Found in services/tools.js and 1 other location - About 1 hr to fix
                                services/tools.js on lines 157..165

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

                                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 (archName === 'ecp5') {
                                              // LPF file
                                              var lpfFile = compiler.generate('lpf', project.get(), opt)[0];
                                              nodeFs.writeFileSync(
                                                nodePath.join(common.BUILD_DIR, lpfFile.name),
                                Severity: Major
                                Found in services/tools.js and 1 other location - About 1 hr to fix
                                services/tools.js on lines 165..173

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

                                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

                                        for (i in collection.examples) {
                                          dest = collection.examples[i].replace(pattern, collection.name);
                                          safeExtract(collection.examples[i], dest, zip);
                                        }
                                Severity: Major
                                Found in services/tools.js and 1 other location - About 1 hr to fix
                                services/tools.js on lines 1005..1008

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

                                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

                                        for (i in collection.blocks) {
                                          dest = collection.blocks[i].replace(pattern, collection.name);
                                          safeExtract(collection.blocks[i], dest, zip);
                                        }
                                Severity: Major
                                Found in services/tools.js and 1 other location - About 1 hr to fix
                                services/tools.js on lines 1009..1012

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

                                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 (collection.package) {
                                          dest = collection.package.replace(pattern, collection.name);
                                          safeExtract(collection.package, dest, zip);
                                        }
                                Severity: Minor
                                Found in services/tools.js and 1 other location - About 40 mins to fix
                                services/tools.js on lines 1035..1038

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

                                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 (collection.readme) {
                                          dest = collection.readme.replace(pattern, collection.name);
                                          safeExtract(collection.readme, dest, zip);
                                        }
                                Severity: Minor
                                Found in services/tools.js and 1 other location - About 40 mins to fix
                                services/tools.js on lines 1031..1034

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

                                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

                                              } else if (
                                                stdout.indexOf(
                                                  'Error: board ' + boardName + ' not available'
                                                ) !== -1
                                              ) {
                                Severity: Minor
                                Found in services/tools.js and 1 other location - About 35 mins to fix
                                services/tools.js on lines 357..380

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

                                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

                                                    } else if (
                                                      stdout.indexOf('Device or resource busy') !== -1
                                                    ) {
                                                      resultAlert = alertify.error(
                                                        _tcStr('Board {{name}} not available', {
                                Severity: Minor
                                Found in services/tools.js and 1 other location - About 35 mins to fix
                                services/tools.js on lines 332..571

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

                                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